@@ -88,7 +88,7 @@ void runAppOnce(TestConfig config, Agent agent) throws Exception {
8888 writeStartupTimeFile (agent , start );
8989
9090 if (config .getWarmupSeconds () > 0 ) {
91- doWarmupPhase (config );
91+ doWarmupPhase (config , petclinic );
9292 }
9393
9494 long testStart = System .currentTimeMillis ();
@@ -115,28 +115,37 @@ private void startRecording(Agent agent, GenericContainer<?> petclinic) throws E
115115 "jcmd" ,
116116 "1" ,
117117 "JFR.start" ,
118- "settings=profile " ,
118+ "settings=/app/overhead.jfc " ,
119119 "dumponexit=true" ,
120120 "name=petclinic" ,
121121 "filename=" + outFile
122122 };
123123 petclinic .execInContainer (command );
124124 }
125125
126- private void doWarmupPhase (TestConfig testConfig ) {
127- long start = System .currentTimeMillis ();
128- System .out .println (
129- "Performing startup warming phase for " + testConfig .getWarmupSeconds () + " seconds..." );
130- while (TimeUnit .MILLISECONDS .toSeconds (System .currentTimeMillis () - start )
131- < testConfig .getWarmupSeconds ()) {
126+ private void doWarmupPhase (TestConfig testConfig , GenericContainer <?> petclinic ) throws IOException , InterruptedException {
127+ System .out .println ("Performing startup warming phase for " + testConfig .getWarmupSeconds () + " seconds..." );
128+
129+ // excluding the JFR recording from the warmup causes strange inconsistencies in the results
130+ System .out .println ("Starting disposable JFR warmup recording..." );
131+ String [] startCommand = {"jcmd" , "1" , "JFR.start" , "settings=/app/overhead.jfc" , "dumponexit=true" , "name=warmup" , "filename=warmup.jfr" };
132+ petclinic .execInContainer (startCommand );
133+
134+ long deadline = System .currentTimeMillis () + TimeUnit .SECONDS .toMillis (testConfig .getWarmupSeconds ());
135+ while (System .currentTimeMillis () < deadline ) {
132136 GenericContainer <?> k6 =
133137 new GenericContainer <>(DockerImageName .parse ("loadimpact/k6" ))
134138 .withNetwork (NETWORK )
135139 .withCopyFileToContainer (MountableFile .forHostPath ("./k6" ), "/app" )
136- .withCommand ("run" , "-u" , "5" , "-i" , "25 " , "/app/basic.js" )
140+ .withCommand ("run" , "-u" , "5" , "-i" , "200 " , "/app/basic.js" )
137141 .withStartupCheckStrategy (new OneShotStartupCheckStrategy ());
138142 k6 .start ();
139143 }
144+
145+ System .out .println ("Stopping disposable JFR warmup recording..." );
146+ String [] stopCommand = {"jcmd" , "1" , "JFR.stop" , "name=warmup" };
147+ petclinic .execInContainer (stopCommand );
148+
140149 System .out .println ("Warmup complete." );
141150 }
142151
0 commit comments