Блог пользователя efimovpaul

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

Hello, Codeforces!!


Guys, how do you stress-test your solutions? I know at least three possible ways to do it.

1)Right in your solution file
Write second stress-solution ( definitly correct, but quite slow ), generator, checker, ect. right in your solution file as functions and call functions from main.
I personally use this variant, it is fast and convinient. But there is one problem using this method.. When you have your solution fixed, you have to comment all your stress-code.. I have a trick: just make copy of your file before adding stress-testing functions and add them in your second file, after debugging you will have to just fix jour solution in the first file.

2)Python script
Some people write Python scripts to stress their solutions. You have two programs: solution with bug and stress-solution. So you can just generate tests, lauch your solutions, check answers, etc. from Python script.

3)Bash or maybe Bat scripts
Method is idiologically similar to the 2)Python script, but you write bash/bat scripts.


Which method do you use? Or maybe you have your own techniques, share in comments.

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

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

Too much stress can be detrimental to their performance. Codes need a caring and minimal stress environment to foster their growth.

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

Big eye big brain method: Try to come up with nasty inputs and run them.

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

I use FastOlympicCoding's stress in sublime text. And it's usage is like the second one. All we need is a correct solution, a wrong solution and a generator file.

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

Hi! Firstly I use ubuntu so the bash script may be diffrent if you use windows.I published the codes here.

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

Check this

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

Here's the bash command that I use for stress testing.

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

    do you understand what is happening there? I will be glad if you give me some good resources to learn bash commands, I was quiet surprised when I found out that it is not easy to find full bash-learning courses and videos.

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

Using https://polygon.codeforces.com/ is also an option

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

All I do is write brute force and use this and this

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

I've developed my own system for stress testing, which also allows me to do a ton of customizations, and run multiple tests in parallel.

cfstress.com

Although behind the scenes, it'd fall under category 3.

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

    wow, nice job!! is only online version available? online versions are not allowed to use during some olympiads, maybe you have something like "portable version"?

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

    in addition to the previous comment, it asks the number of CF problem, so is it important for problem to exist on CF? you get input format from there? is it possible to make your utility work using just problem's statement text?

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

      No, it's not important for the problem to exist on Codeforces (for example, I also use it for Atcoder Beginner Contests). But that feature is only available on the portable version.

      However, don't get the impression that it uses Machine Learning to parse problems and generate test automatically. It doesn't. But I have created various scripts, header files and macros that allow me to feed the data in a fixed format and it generates the test cases off of that. There's definitely a little coding required for each problem, but it's just 5 to 10 minutes of effort per problem. (If it takes more than 15 minutes, it's not worth stress testing IMO).

      For example, for the last Edu Round, it took ms around 30 minutes to create generators for all 6 problems.

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

I use CodePal

»
4 года назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +3 Проголосовать: не нравится

I can suggest IFDEF for C++, and if statement check for python. If you write ur code in python, you can create decorator which checks if code is used locally (for example using os.getlogin()), and place it right before ur stress tests and they will be skipped.

import os

def ignore(func):
    if os.getlogin() == "doreshnikov":
        func()
    else:
        pass

@ignore
def stress():
    print(123)
»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why not to always use first option + #ifdef? The only downside is that you should be a bit more careful with random and multitests, but if those problems arise, then you are probably doing something wrong.