Skip to content

Commit

Permalink
change approcah
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Oct 12, 2023
1 parent 3f3b6a9 commit 6b5020e
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion tests/general/LoadTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,58 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="s3" {
function run( testResults , testBox ) {
describe( "Loud test", function() {
it( 'make a load test', parallel);

parallel( 'make a load test',10,2, function () {
systemOutput("execute the code",1,1);
assertEquals("a", "b");
});


});

}

private function parallel() threadCount=10 repetitition=2 {
private function parallel(text, threadCount=1, repetitition=1, udf) {
if(arguments.threadcount<1 || arguments.threadcount>1000) {
throw "thread count need to be a number between 1 and 1000, now it is [#arguments.threadcount#]";
}
if(arguments.repetitition<1 || arguments.repetitition>1000) {
throw "repetitition need to be a number between 1 and 1000, now it is [#arguments.repetitition#]";
}
if(arguments.threadcount==1 || arguments.repetitition==1) {
throw "repetitition or thread count need to be bigger than 1";
}

var names = [];
var exceptions = [];
for (var i = 1; i <= arguments.repetitition; i++) {
for (var y = 1; y <= arguments.threadcount; y++) {
var name="testThread:#i#:#y#";
arrayAppend(names, name);
thread action="run" name=name text=arguments.text udf=arguments.udf exceptions=exceptions {
try {
it(text,udf);
}
catch(e) {
//arrayAppend(exceptions, e);
}
}
}
}
thread action="join" name=arrayToList(names);

/*if(len(exceptions)) {
loop array=exceptions item="local.e" {
systemOutput(e,1,1);
}
throw exceptions[1];
}*/

}



private function parallelX() threadCount=10 repetitition=2 {
var udfs=getPageContext().getUDFs();
var meta=getMetadata(udfs[len(udfs)]);

Expand Down

0 comments on commit 6b5020e

Please sign in to comment.