00001 package gov.nasa.arc.ase.jpf;
00002
00003 import gov.nasa.arc.ase.jpf.jvm.VirtualMachine;
00004 import gov.nasa.arc.ase.util.Debug;
00005 import gov.nasa.arc.ase.util.kMG;
00006 import gov.nasa.arc.ase.util.Comma;
00007 import java.io.PrintStream;
00008
00009 class ResultInfo implements java.io.Serializable {
00010
00011 private int race_conditions;
00012
00013
00014 private int GCRuns;
00015
00016
00017 private int GCs;
00018
00019 private int states;
00020 private int transitions;
00021 private long time_used;
00022 private long memory;
00023 private long memory_gc;
00024
00025 private int storage_memory;
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 private int instructions;
00052
00053 public ResultInfo() {
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 }
00068 public ResultInfo(rStatus s) {
00069 Runtime rt = Runtime.getRuntime();
00070
00071
00072 race_conditions = Runner.race_conditions;
00073
00074
00075 GCRuns = Runner.GCRuns;
00076
00077
00078 GCs = Runner.GCs;
00079
00080 states = s.states;
00081 transitions = s.transitions;
00082 time_used = System.currentTimeMillis() - s.begin_time;
00083 memory = (rt.totalMemory() - rt.freeMemory());
00084 rt.gc();
00085 memory_gc = (rt.totalMemory() - rt.freeMemory());
00086
00087 storage_memory = Runner.storage_memory;
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 instructions = Runner.instructions;
00109 }
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 public void print(PrintStream out, String message) {
00155 long minutes = (time_used / 1000) / 60;
00156 long seconds = (time_used / 1000) % 60;
00157 long milliseconds = (time_used % 1000);
00158 String stime_used = minutes + ":";
00159 if (seconds < 10) stime_used = stime_used + "0";
00160 stime_used = stime_used + seconds + ".";
00161 if (milliseconds < 100) stime_used = stime_used + "0";
00162 if (milliseconds < 10) stime_used = stime_used + "0";
00163 stime_used = stime_used + milliseconds + "s";
00164
00165
00166
00167
00168 out.println("\n");
00169 out.println("*******************************");
00170 out.println(message);
00171 out.println("-------------------------------");
00172
00173 if(VirtualMachine.options.race)
00174 out.println("Race conditions : " + race_conditions);
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 out.println("States visited : " + Comma.format(states));
00205 out.println("Transitions executed : " + Comma.format(transitions));
00206 out.println("Instructions executed: " + Comma.format(instructions));
00207 out.println("Memory Usage : " + kMG.format(memory));
00208 out.println("Memory Usage gc : " + kMG.format(memory_gc));
00209
00210 int p = (int)(0.5 + 100.0 * storage_memory / memory_gc);
00211 out.println("Storage Memory : " + kMG.format(storage_memory) + " (" + p + "% of total memory)");
00212
00213
00214
00215
00216 out.println("Time (min:sec:msec) : " + stime_used);
00217 out.println("Speed (transition/s) : " + Comma.format(speed(transitions,time_used)) + "t/s");
00218 out.println("Speed (instruction/s): " + Comma.format(speed(instructions,time_used)) + "i/s");
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 out.println("*******************************");
00261 }
00262 public void print(String message) {
00263 long minutes = time_used / 60000;
00264 long seconds = (time_used / 1000) % 60;
00265 long milliseconds = time_used % 1000;
00266 String stime_used = minutes + ":";
00267 if (seconds < 10) stime_used = stime_used + "0";
00268 stime_used = stime_used + seconds + ".";
00269 if (milliseconds < 100) stime_used = stime_used + "0";
00270 if (milliseconds < 10) stime_used = stime_used + "0";
00271 stime_used = stime_used + milliseconds + "s";
00272
00273
00274
00275
00276 Debug.println(Debug.WARNING, "\n");
00277 Debug.println(Debug.WARNING, "*******************************");
00278 Debug.println(Debug.WARNING, message);
00279 Debug.println(Debug.WARNING, "-------------------------------");
00280
00281 if(VirtualMachine.options.race)
00282 Debug.println(Debug.WARNING, "Race conditions : " + race_conditions);
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312 Debug.println(Debug.WARNING, "States visited : " + Comma.format(states));
00313 Debug.println(Debug.WARNING, "Transitions executed : " + Comma.format(transitions));
00314 Debug.println(Debug.WARNING, "Instructions executed: " + Comma.format(instructions));
00315 Debug.println(Debug.WARNING, "Memory Usage : " + kMG.format(memory));
00316 Debug.println(Debug.WARNING, "Memory Usage gc : " + kMG.format(memory_gc));
00317
00318 int p = (int)(0.5 + 100.0 * storage_memory / memory_gc);
00319 Debug.println(Debug.WARNING, "Storage Memory : " + kMG.format(storage_memory) + " (" + p + "% of total memory)");
00320
00321
00322
00323
00324
00325 if(VirtualMachine.options.garbage_collection) {
00326
00327 Debug.println(Debug.WARNING, "GC runs : " + GCRuns);
00328
00329 Debug.println(Debug.WARNING, "Objects Collected : " + GCs);
00330 }
00331
00332 Debug.println(Debug.WARNING, "Time (min:sec:msec) : " + stime_used);
00333 Debug.println(Debug.WARNING, "Speed (transition/s) : " + Comma.format(speed(transitions,time_used)) + "t/s");
00334 Debug.println(Debug.WARNING, "Speed (instruction/s): " + Comma.format(speed(instructions,time_used)) + "i/s");
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374 Debug.println(Debug.WARNING, "*******************************");
00375 }
00376 public void setTimeUsed(long t) {
00377 time_used = t;
00378 }
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413 public static long speed(long ticks, long time) {
00414 double a = (double)ticks;
00415 double b = (double)time;
00416
00417 return (long)(a * 1000 / b);
00418 }
00419 }