art-hack's blog

By art-hack, history, 5 years ago, In English

Hello Everyone,

I have created a handy tool for running two codes against an input or stress testing them against random inputs. This can be helpful in hacking some simple problems and get possible faults, and also in finding wrong test cases for your solutions.

Link to Github Repo: Link

Video Showing its working Watch the video

I know this isn't perfect so if you feel that I can improve something or add some feature then do let me know and feel free to contribute as well.

  • Vote: I like it
  • +48
  • Vote: I do not like it

»
5 years ago, # |
  Vote: I like it -13 Vote: I do not like it

Great, thanks! Hope you get high rated! :)

»
5 years ago, # |
  Vote: I like it +1 Vote: I do not like it

You created tool by writing more than 200 lines of code for thing which you can do with few simple BASH commands? O_o
Definitely the biggest bicycle invention which I saw in the last time.

Mentioned BASH commands
  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it +24 Vote: I do not like it

    It doesn't include multithreading and stress testing. Also, I created it as a start point and was looking for possible improvements/features with help from the community.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Hmm, it IS stress testing — comparing your solution (A.cpp) with some kind of bruteforce (B.cpp) on many random testcases (input.txt).

      • »
        »
        »
        »
        5 years ago, # ^ |
        Rev. 2   Vote: I like it +13 Vote: I do not like it

        Here, by stress testing, I meant to keep testing until you find a case where the outputs do not match for both the inputs. To put it simply, generating random cases again and again until outputs mismatch. If you are using a really big file, then you may have to:

        • Change the original programs to add test cases(T).
        • Wait for the whole file input to finish to know the result.
        • If no such case is found, recreate the test file and rerun the same thing.
        • »
          »
          »
          »
          »
          5 years ago, # ^ |
          Rev. 2   Vote: I like it +27 Vote: I do not like it

          In bash:

          while diff a_out b_out
          do
              ./gen > inp
              ./a < inp > a_out
              ./b < inp > b_out
          done
          
    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      And about multithreading: it is just useless in python because of GIL. So, actually, you don't run tests parallelly in such a way.

      • »
        »
        »
        »
        5 years ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        Indeed you're correct about multithreading and thanks for that, but I can include multiprocessing to get the desired boost. I am not saying that I invented something and i am sure you can very well create a script in bash to get the desired function, the sole purpose is to share with anyone who may find it useful. You do know, that one can learn while building that already invented bicycle.

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        The multithreading in this case does work, because most of the work is done in the spawned subprocesses.

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          True, trying to find a way to fix that as well.

»
5 years ago, # |
  Vote: I like it +1 Vote: I do not like it

i think this can be useful ! suggestion : add tle checker