00001 package gov.nasa.arc.ase.jpf;
00002
00003 import java.io.Serializable;
00004
00005 import gov.nasa.arc.ase.util.Debug;
00006 import gov.nasa.arc.ase.util.Comma;
00007 import gov.nasa.arc.ase.util.kMG;
00008 import gov.nasa.arc.ase.util.hms;
00009
00010 import gov.nasa.arc.ase.jpf.jvm.VirtualMachine;
00011
00012
00013
00014
00015 public class Status implements Serializable {
00016
00017
00018
00019 public int states = 0;
00020
00021
00022
00023
00024 public int transitions = 0;
00025
00026
00027
00028
00029 public int instructions = 0;
00030
00031
00032
00033
00034 public long memory = 0;
00035
00036
00037
00038
00039
00040 public long memoryGC = 0;
00041
00042
00043
00044
00045 public int storageMemory = 0;
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 public int GCRuns = 0;
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 public int GCs = 0;
00117
00118
00119
00120
00121
00122
00123 public static long startingTime = System.currentTimeMillis();
00124
00125
00126
00127
00128 public int maxStackDepth = 0;
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 public int intermediateTransitions = 0;
00153
00154
00155
00156
00157
00158
00159 public int unique = 0;
00160
00161
00162
00163
00164
00165
00166 public Status() {
00167 }
00168
00169
00170
00171
00172
00173 public Status(Status s) {
00174 states = s.states;
00175 transitions = s.transitions;
00176 instructions = s.instructions;
00177 memory = s.memory;
00178 memoryGC = s.memoryGC;
00179 storageMemory = s.storageMemory;
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 GCRuns = s.GCRuns;
00191
00192
00193 GCs = s.GCs;
00194
00195 maxStackDepth = s.maxStackDepth;
00196
00197
00198
00199
00200
00201
00202 intermediateTransitions = s.intermediateTransitions;
00203
00204 unique = s.unique;
00205
00206 }
00207
00208
00209
00210 public void add(Status s) {
00211 states += s.states;
00212 transitions += s.transitions;
00213 instructions += s.instructions;
00214 memory += s.memory;
00215 memoryGC += s.memoryGC;
00216 storageMemory += s.storageMemory;
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 GCRuns += s.GCRuns;
00228
00229
00230
00231 GCs += s.GCs;
00232
00233
00234 maxStackDepth = Math.max(maxStackDepth, s.maxStackDepth);
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 intermediateTransitions += s.intermediateTransitions;
00248
00249
00250
00251 unique += unique;
00252
00253
00254
00255 }
00256
00257
00258
00259 public void print() {
00260 updateMemoryUsage();
00261 long currentTime = System.currentTimeMillis();
00262 double deltaTime = currentTime - startingTime;
00263 int speed = (int)((transitions / deltaTime) * 1000);
00264
00265 Debug.println(Debug.ERROR, "-----------------------------------");
00266 Debug.println(Debug.ERROR, "States visited : " + Comma.format(states));
00267
00268 if(Engine.options.buchi != null)
00269 Debug.println(Debug.ERROR, "System states : " + Comma.format(unique));
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 Debug.println(Debug.ERROR, "Transitions executed : " + Comma.format(transitions));
00285 Debug.println(Debug.ERROR, "Instructions executed: " + Comma.format(instructions));
00286
00287
00288
00289
00290
00291
00292
00293
00294 if(Engine.options.verify)
00295 Debug.println(Debug.ERROR, "Maximum stack depth : " + Comma.format(maxStackDepth));
00296 Debug.println(Debug.ERROR, "Intermediate steps : " + Comma.format(intermediateTransitions));
00297 Debug.println(Debug.ERROR, "Memory used : " + kMG.format(memory) + "B");
00298 Debug.println(Debug.ERROR, "Memory used after gc : " + kMG.format(memoryGC) + "B");
00299 Debug.println(Debug.ERROR, "Storage memory : " + kMG.format(storageMemory) + "B");
00300
00301 if(VirtualMachine.options.garbage_collection)
00302 Debug.println(Debug.ERROR, "Collected objects : " + Comma.format(GCs));
00303
00304
00305 if(VirtualMachine.options.garbage_collection) {
00306 Debug.print(Debug.ERROR, "Mark and sweep runs : ");
00307 Debug.println(Debug.ERROR, Comma.format(GCRuns));
00308 }
00309
00310 Debug.println(Debug.ERROR, "Execution time : " + hms.format((long)deltaTime) + "s");
00311 Debug.println(Debug.ERROR, "Speed : " + Comma.format(speed) + "tr/s");
00312 Debug.println(Debug.ERROR, "-----------------------------------");
00313 }
00314 public int report(long deltaTime, int lastReportTransitions) {
00315 updateMemoryUsage();
00316 double deltaTransitions = transitions - lastReportTransitions;
00317 int speed = (int)((deltaTransitions/deltaTime) * 1000);
00318
00319 Debug.println(Debug.WARNING,
00320 Comma.format(states) +
00321 " tr " + Comma.format(transitions) +
00322 " sd " + Comma.format(maxStackDepth) +
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 " spd " + Comma.format(speed) + "tr/s" +
00334 " mem " + kMG.format(memory));
00335
00336
00337
00338
00339 return transitions;
00340 }
00341
00342
00343
00344 public void updateMemoryUsage() {
00345 Runtime runtime = Runtime.getRuntime();
00346
00347 memory = runtime.totalMemory() - runtime.freeMemory();
00348 runtime.gc();
00349 memoryGC = runtime.totalMemory() - runtime.freeMemory();
00350 }
00351 }