Блог пользователя art-hack

Автор art-hack, история, 4 года назад, По-английски

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.

  • Проголосовать: нравится
  • +48
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится -13 Проголосовать: не нравится

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

»
4 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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
  • »
    »
    4 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +24 Проголосовать: не нравится

    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.

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

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

      • »
        »
        »
        »
        4 года назад, # ^ |
        Rev. 2   Проголосовать: нравится +13 Проголосовать: не нравится

        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.
        • »
          »
          »
          »
          »
          4 года назад, # ^ |
          Rev. 2   Проголосовать: нравится +27 Проголосовать: не нравится

          In bash:

          while diff a_out b_out
          do
              ./gen > inp
              ./a < inp > a_out
              ./b < inp > b_out
          done
          
    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

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

      • »
        »
        »
        »
        4 года назад, # ^ |
        Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

        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.

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

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

»
4 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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