Created
March 19, 2013 20:31
-
-
Save munificent/5199833 to your computer and use it in GitHub Desktop.
This is my little script for stress-testing a Dart program. Change `script_to_run.dart` to the name of the Dart script to run. Make sure that script ends with a non-zero exit code to indicate failure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io'; | |
const MAX_ATTEMPTS = 10000; | |
const MAX_JOBS = 20; | |
var total = 0; | |
var numRunning = 0; | |
main() { | |
for (var i = 0; i < MAX_JOBS; i++) spawnProc(); | |
} | |
spawnProc() { | |
numRunning++; | |
Process.run('dart', ['--checked', 'script_to_run.dart']).then((result) { | |
total++; | |
numRunning--; | |
if (result.exitCode != 0) { | |
print("$total $numRunning: ${result.exitCode} ${result.stdout}"); | |
} | |
if (total < MAX_ATTEMPTS && numRunning < MAX_JOBS) spawnProc(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment