Naim's blog

By Naim, history, 4 years ago, In English

After watching Errichto's this video on testing solutions I have created a powershell script for that. But when I run my script it runs more than 50 times slower than bash script what Errichto has shown in his video.

My question is, is there any way to improve the runtime of this powershell script? And It would be awesome if others share how they use script for debugging in contest time.

My powershell script:

for ($i = 0; ; $i++) { 
    Write-Output "$i"
    Start-Process .\Generator.exe -RedirectStandardOutput .\in -NoNewWindow -Wait
    Start-Process .\Brute.exe -RedirectStandardInput .\in -RedirectStandardOutput .\out1 -NoNewWindow -Wait
    Start-Process .\Error.exe -RedirectStandardInput .\in -RedirectStandardOutput .\out2 -NoNewWindow -Wait
    if ((Get-FileHash .\out1).Hash -ne (Get-FileHash .\out2).Hash) {
        Compare-Object (Get-Content out1) (Get-Content out2)
        break
    }
}
  • Vote: I like it
  • +9
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it +11 Vote: I do not like it

I'm not a Windows expert but maybe compare your script with this one by ADJA http://webcache.googleusercontent.com/search?q=cache:N2VFVE2MDGIJ:www.algos.school/stress-testing+&cd=1&hl=en&ct=clnk&gl=pl

(cache link because the original one is dead)

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

    I brought the website down just yesterday, lol, because my free Google Cloud credit was expiring and I wasn't updating content anymore.

    That said, there are several outdated things in the scripts in the article. Lately, when writing stress tests, I don't pass random seed to the generator, and simply use this function to generate random stuff:

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int getRandom(int from, int to) {
      return uniform_int_distribution<int>(from, to)(rng);
    }
    

    Source

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

      Thanks Errichto for sharing the link to that awesome blog. And Thanks ADJA for creating that blog post. It is very much informative.

      I've got where the problem is in my script. I'm compiling three files again and again, where I had to compile just one time and use executable files repetitively. But I don't know how to do that :). Anyway, using a batch file is also awesome.

      Thanks again :D