NeroZein's blog

By NeroZein, history, 13 months ago, In English

Since our TST is near (25 / 4), I was thinking about a way to stress test my code on windows without having to write a messy code or a 100 lines script, is this possible in some way ?

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

| Write comment?
»
13 months ago, # |
  Vote: I like it +10 Vote: I do not like it

Hi!

First of all, good luck on the TST!

Now, I can only tell you how I usually do stress testing, which I don't think it's particularly messy. I usually have two functions, the bruteforce and the buggy solution, to which you pass the input as parameters. I don't think it can get much cleaner than this without scripts.

All you have to do is generate the input in main and pass it to the functions, until you find some input for which the answers are different.

I don't know if this is what you wanted to know, feel free to ask if not. Also, I can't find an example right now but if you're really interested I can try to look more in depth.

  • »
    »
    13 months ago, # ^ |
      Vote: I like it -9 Vote: I do not like it

    Hi. I want to more talk about it. Are you good at programming?

    • »
      »
      »
      13 months ago, # ^ |
        Vote: I like it +21 Vote: I do not like it

      No, unfortunately I'm bad at programming, but I can discuss it with you, if you want.

  • »
    »
    13 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks !

    I've actually tried doing this but it's sometimes really painful when you're using global arrays or other stuff

    I'd be thankful if you could provide some impl advices tho

    • »
      »
      »
      13 months ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      I usually don't use global variables, I like to pass everything but reference, but when I use them what I usually do is put everything inside of classes.

      Like, all the variables I need for one function + the function inside a class, and having two separate classes, one for the brute and one for the buggy sol, then you can stress test without many problems.

»
13 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Check this blog

»
13 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I have a .bat file that does it for me

Spoiler

and i run it from cmd window

  • »
    »
    13 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I can't write all of this inside a 5 hours contest not to mention it's hard to remember

    • »
      »
      »
      13 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      A bare-bones version, failing input will be in b.in, otherwise it will run forever (you can stop it by pressing CTRL+C).

      @echo off
      g++ good.cpp -o good.exe
      g++ gen.cpp -o gen.exe
      g++ bad.cpp -o bad.exe
      :start
        gen.exe > b.in
        good.exe < b.in > good.out
        bad.exe < b.in > bad.out
        fc /c good.out bad.out > fc.txt
      if %errorlevel%==0 goto start
      
»
13 months ago, # |
  Vote: I like it 0 Vote: I do not like it

You can use Codepal for stress test.

»
13 months ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

If you don't want to write code, you're gonna need to use a tool, which is unallowed. Just write code on your own. Also I remember Coach Geo told me that we're not going to use our computers. Not sure though.

  • »
    »
    13 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I guess we are not using ours

    • »
      »
      »
      13 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Yes. Also the place we're staying in has computers so I guess that's it

»
13 months ago, # |
  Vote: I like it +1 Vote: I do not like it

I think this bash script might be what you are looking for (easy and clean):

for((i = 1; ; ++i)); do echo $i ./gen $i > int diff -w <(./a < int) <(./brute < int) || break done

  • »
    »
    13 months ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    does this work on windows ?

    I use something like this on Linux and it's great

    • »
      »
      »
      13 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I haven't tried, I use Linux as well.

      • »
        »
        »
        »
        13 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Sadly, windows uses Batch instead of Bash so this won't work