项目作者: bhupixb

项目描述 :
Stress testing solutions for Competitive Programming
高级语言: C++
项目地址: git://github.com/bhupixb/Stress-Testing-bash-script.git
创建时间: 2020-06-17T18:28:25Z
项目社区:https://github.com/bhupixb/Stress-Testing-bash-script

开源协议:

下载


Note: A Codeforces blog can be found here on Codeforces.

Stress Testing bash script

A simple bash script which stress tests an optimized solution & a brute
force solution on randomly generated testcases, to find a possible failing testcase.

Usage

Clone this repository using git or download manually.

  1. # Clone the Repository.
  2. $ git clone https://github.com/bhupixb/Stress-Testing-bash-script
  3. # Change directory.
  4. $ cd Stress-Testing-bash-script
  5. # Give execute permission to `stress_test` script to current user.
  6. $ sudo chmod u+x stress_test
  7. # Assuming your optmized solution is in main.cpp and brute force solution
  8. # in brute.cpp, to run stress test:
  9. $ ./stress_test -b brute.cpp -m main.cpp
  10. # To print usage, use -h flag
  11. $ ./stress_test -h

Usage Screenshot

When to use:

This is useful when your optimized solution is failing on some test case during a contest

and you are unable to come up with a failing test case.

In cases like this if you write a brute force solution that you are sure that will produce
correct output and run these 2 solutions on random tests, it can help
you find a test case which fails on your main solution.

How it works:

  1. This script takes your main solution and brute force solution cpp file as argument.
  2. Compiles the code & generates executable.
  3. Generates testcases(default 10) from tc_generator.cpp program and runs your main & brute solution
    against it. Then it checks for difference in output of both solutions, if it differs, the
    script reports the testcase, output of your main solution and output of your brute force
    solution to your terminal STDOUT.
  4. Now you can figure out, what’s wrong in your solution given a test case on which your sol
    fails.

Testcase Generator:

The file tc_generator.cpp has some boilerplate code to generate commonly
required testcases like tree, graph, array of integers & strings.

You can modify this file to generate test cases as per your requirements. E.g.
1) to generate an array calling:
gen_array(10, -5, 10);
it will return an array(vector more specifically) with length 10 and elements in the range [-5, 10].

2) to generate a tree calling:
gen_tree(10):
will return a tree with 10 nodes.

3) to generate a simple graph calling:
gen_simple_graph(10, 12);
will return a simple connected graph with 10 nodes and 12 edges.

You can add things as you need them or use testlib which is the best if you know how to use it.