@@ -198,21 +198,69 @@ public static void main(String[] args) throws Exception {
198
198
numTxnTypes = xmlConfig .configurationsAt ("transactiontypes" + pluginTest + "/transactiontype" ).size ();
199
199
}
200
200
201
- List <HierarchicalConfiguration <ImmutableNode >> workloads = xmlConfig .configurationsAt ("microbenchmark/properties/executeRules" );
201
+ List <HierarchicalConfiguration <ImmutableNode >> workloads =
202
+ xmlConfig .configurationsAt ("microbenchmark/properties/executeRules" );
202
203
203
- int totalworkcount = plugin .equalsIgnoreCase ("featurebench" ) ? (workloads == null ? 1 : (workloads .size () == 0 ? 1 : workloads .size ())) : 1 ;
204
+ int totalWorkloadCount =
205
+ plugin .equalsIgnoreCase ("featurebench" ) ?
206
+ (workloads == null ? 1 : (workloads .size () == 0 ? 1 : workloads .size ())) : 1 ;
204
207
205
208
boolean createDone = false ;
206
209
boolean loadDone = false ;
207
210
208
- for (int workcount = 1 ; workcount <= totalworkcount ; workcount ++) {
209
211
210
- List <HierarchicalConfiguration <ImmutableNode >> executeRules = (workloads == null || workloads .size () == 0 ) ? null : workloads .get (workcount - 1 ).configurationsAt ("run" );
211
- if (executeRules == null ) {
212
- LOG .info ("Starting Workload " + workcount );
212
+ Set <String > uniqueRunWorkloads = new HashSet <>();
213
+ List <String > workloadsFromExecuteRules = new ArrayList <>();
214
+
215
+ if (workloads != null && workloads .size () != 0 ) {
216
+ for (int workCount = 1 ; workCount <= totalWorkloadCount ; workCount ++) {
217
+ workloadsFromExecuteRules .add (workloads .get (workCount - 1 )
218
+ .containsKey ("workload" ) ? workloads .get (workCount - 1 )
219
+ .getString ("workload" ) : String .valueOf (workCount ));
220
+ }
221
+ }
222
+
223
+ String fileForAllWorkloadList = "allWorkloads" + ".txt" ;
224
+ try (PrintStream ps = new PrintStream (FileUtil .joinPath (fileForAllWorkloadList ))) {
225
+ if (workloads != null && workloads .size () != 0 ) {
226
+ System .out .println ("All Workloads:" );
227
+ for (int workCount = 1 ; workCount <= totalWorkloadCount ; workCount ++) {
228
+ ps .println ((workloads .get (workCount - 1 )
229
+ .containsKey ("workload" ) ? workloads .get (workCount - 1 ).getString ("workload" ) : workCount ));
230
+ System .out .println ((workloads .get (workCount - 1 )
231
+ .containsKey ("workload" ) ? workloads .get (workCount - 1 ).getString ("workload" ) : workCount ));
232
+ }
233
+ }
234
+ }
235
+
236
+ if (isBooleanOptionSet (argsLine , "execute" )) {
237
+ String targetWorkloads ;
238
+ List <String > RunWorkloads ;
239
+ if ((argsLine .hasOption ("workloads" )) && !argsLine .getOptionValue ("workloads" ).isEmpty ()) {
240
+ targetWorkloads = argsLine .getOptionValue ("workloads" );
241
+ RunWorkloads = List .of (targetWorkloads .trim ().split ("\\ s*,\\ s*" ));
242
+ uniqueRunWorkloads .addAll (RunWorkloads );
243
+ uniqueRunWorkloads .forEach (uniqueWorkload -> {
244
+ if (workloadsFromExecuteRules .contains (uniqueWorkload )) {
245
+ LOG .info ("Workload: " + uniqueWorkload + " will be scheduled to run" );
246
+ } else {
247
+ throw new RuntimeException ("Wrong workload name provided in --workloads args: " + uniqueWorkload );
248
+ }
249
+ });
213
250
} else {
214
- LOG .info ("Starting Workload " + (workloads .get (workcount - 1 ).containsKey ("workload" ) ? workloads .get (workcount - 1 ).getString ("workload" ) : workcount ));
251
+ workloadsFromExecuteRules
252
+ .forEach (workloadFromExecuteRule -> LOG .info ("Workload: "
253
+ + workloadFromExecuteRule + " will be scheduled to run" ));
215
254
}
255
+ }
256
+
257
+
258
+ for (int workCount = 1 ; workCount <= totalWorkloadCount ; workCount ++) {
259
+
260
+ List <HierarchicalConfiguration <ImmutableNode >> executeRules =
261
+ (workloads == null || workloads .size () == 0 ) ? null : workloads .get (workCount - 1 )
262
+ .configurationsAt ("run" );
263
+
216
264
217
265
boolean isExecutePresent = xmlConfig .containsKey ("microbenchmark/properties/execute" );
218
266
boolean isExecuteTrue = false ;
@@ -570,12 +618,41 @@ public static void main(String[] args) throws Exception {
570
618
LOG .debug ("Skipping loading benchmark database records" );
571
619
}
572
620
621
+
622
+ if (isBooleanOptionSet (argsLine , "execute" ) && (argsLine .hasOption ("workloads" )) && executeRules != null ) {
623
+ String val = workloads .get (workCount - 1 ).getString ("workload" );
624
+ if (uniqueRunWorkloads .contains (val )) {
625
+ LOG .info ("Starting Workload " + (workloads .get (workCount - 1 ).containsKey ("workload" ) ? workloads .get (workCount - 1 ).getString ("workload" ) : workCount ));
626
+ try {
627
+ Results r = runWorkload (benchList , intervalMonitor , workCount );
628
+ writeOutputs (r , activeTXTypes , argsLine , xmlConfig , executeRules == null ? null : workloads .get (workCount - 1 ).getString ("workload" ));
629
+ writeHistograms (r );
630
+
631
+ if (argsLine .hasOption ("json-histograms" )) {
632
+ String histogram_json = writeJSONHistograms (r );
633
+ String fileName = argsLine .getOptionValue ("json-histograms" );
634
+ FileUtil .writeStringToFile (new File (fileName ), histogram_json );
635
+ LOG .info ("Histograms JSON Data: " + fileName );
636
+ }
637
+ } catch (Throwable ex ) {
638
+ LOG .error ("Unexpected error when executing benchmarks." , ex );
639
+ System .exit (1 );
640
+ }
641
+ }
642
+ }
643
+
644
+
573
645
// Execute Workload
574
- if (isBooleanOptionSet (argsLine , "execute" )) {
646
+ else if (isBooleanOptionSet (argsLine , "execute" )) {
647
+ if (executeRules == null ) {
648
+ LOG .info ("Starting Workload " + workCount );
649
+ } else {
650
+ LOG .info ("Starting Workload " + (workloads .get (workCount - 1 ).containsKey ("workload" ) ? workloads .get (workCount - 1 ).getString ("workload" ) : workCount ));
651
+ }
575
652
// Bombs away!
576
653
try {
577
- Results r = runWorkload (benchList , intervalMonitor , workcount );
578
- writeOutputs (r , activeTXTypes , argsLine , xmlConfig , executeRules == null ? null : workloads .get (workcount - 1 ).getString ("workload" ));
654
+ Results r = runWorkload (benchList , intervalMonitor , workCount );
655
+ writeOutputs (r , activeTXTypes , argsLine , xmlConfig , executeRules == null ? null : workloads .get (workCount - 1 ).getString ("workload" ));
579
656
writeHistograms (r );
580
657
581
658
if (argsLine .hasOption ("json-histograms" )) {
@@ -613,6 +690,7 @@ private static Options buildOptions(XMLConfiguration pluginConfig) {
613
690
options .addOption ("d" , "directory" , true , "Base directory for the result files, default is current directory" );
614
691
options .addOption (null , "dialects-export" , true , "Export benchmark SQL to a dialects file" );
615
692
options .addOption ("jh" , "json-histograms" , true , "Export histograms to JSON file" );
693
+ options .addOption ("workloads" , "workloads" , true , "Run some specific workloads" );
616
694
return options ;
617
695
}
618
696
0 commit comments