3
3
// Licensed under the terms of the GNU LGPL; see COPYING for details.
4
4
package com .github .javabdd ;
5
5
6
+ import java .util .ArrayList ;
6
7
import java .util .Arrays ;
7
8
import java .util .BitSet ;
8
9
import java .util .Collection ;
@@ -1235,16 +1236,20 @@ public ReorderStats getReorderStats() {
1235
1236
* Stores statistics about the operator cache.
1236
1237
*
1237
1238
* @author jwhaley
1239
+ * @author sthuijsman
1240
+ * @author mgoorden
1238
1241
* @version $Id: BDDFactory.java 480 2010-11-16 01:29:49Z robimalik $
1239
1242
*/
1240
1243
public static class CacheStats {
1241
- public int uniqueAccess ;
1242
- public int uniqueChain ;
1243
- public int uniqueHit ;
1244
- public int uniqueMiss ;
1245
- public int opHit ;
1246
- public int opMiss ;
1247
- public int swapCount ;
1244
+ protected boolean enabled = false ;
1245
+ public long uniqueAccess ;
1246
+ public long uniqueChain ;
1247
+ public long uniqueHit ;
1248
+ public long uniqueMiss ;
1249
+ public long opAccess ;
1250
+ public long opHit ;
1251
+ public long opMiss ;
1252
+ public long swapCount ;
1248
1253
1249
1254
protected CacheStats () { }
1250
1255
@@ -1253,11 +1258,31 @@ void copyFrom(CacheStats that) {
1253
1258
this .uniqueChain = that .uniqueChain ;
1254
1259
this .uniqueHit = that .uniqueHit ;
1255
1260
this .uniqueMiss = that .uniqueMiss ;
1261
+ this .opAccess = that .opAccess ;
1256
1262
this .opHit = that .opHit ;
1257
1263
this .opMiss = that .opMiss ;
1258
1264
this .swapCount = that .swapCount ;
1259
1265
}
1260
1266
1267
+ public void enableMeasurements () {
1268
+ enabled = true ;
1269
+ }
1270
+
1271
+ public void disableMeasurements () {
1272
+ enabled = false ;
1273
+ }
1274
+
1275
+ public void resetMeasurements () {
1276
+ uniqueAccess = 0 ;
1277
+ uniqueChain = 0 ;
1278
+ uniqueHit = 0 ;
1279
+ uniqueMiss = 0 ;
1280
+ opAccess = 0 ;
1281
+ opHit = 0 ;
1282
+ opMiss = 0 ;
1283
+ swapCount = 0 ;
1284
+ }
1285
+
1261
1286
/* (non-Javadoc)
1262
1287
* @see java.lang.Object#toString()
1263
1288
*/
@@ -1294,6 +1319,9 @@ public String toString() {
1294
1319
else
1295
1320
sb .append ((float )0 );
1296
1321
sb .append (newLine );
1322
+ sb .append ("Operator Access: " );
1323
+ sb .append (opAccess );
1324
+ sb .append (newLine );
1297
1325
sb .append ("Operator Hits: " );
1298
1326
sb .append (opHit );
1299
1327
sb .append (newLine );
@@ -1327,6 +1355,107 @@ public CacheStats getCacheStats() {
1327
1355
return cachestats ;
1328
1356
}
1329
1357
1358
+ /**
1359
+ * Stores statistics about the maximum BDD nodes usage.
1360
+ *
1361
+ * @author mgoorden
1362
+ */
1363
+ public static class MaxUsedBddNodesStats {
1364
+ protected boolean enabled = false ;
1365
+ protected int maxUsedBddNodes ;
1366
+
1367
+ protected MaxUsedBddNodesStats () { }
1368
+
1369
+ public void enableMeasurements () {
1370
+ enabled = true ;
1371
+ }
1372
+
1373
+ public void disableMeasurements () {
1374
+ enabled = false ;
1375
+ }
1376
+
1377
+ public void resetMeasurements () {
1378
+ maxUsedBddNodes = 0 ;
1379
+ }
1380
+
1381
+ public void newMeasurement (int newUsedBddNodes ) {
1382
+ maxUsedBddNodes = Math .max (newUsedBddNodes , maxUsedBddNodes );
1383
+ }
1384
+
1385
+ public int getMaxUsedBddNodes () {
1386
+ return maxUsedBddNodes ;
1387
+ }
1388
+ }
1389
+
1390
+ /**
1391
+ * Singleton object for maximum used BDD nodes statistics.
1392
+ */
1393
+ protected MaxUsedBddNodesStats maxusedbddnodesstats = new MaxUsedBddNodesStats ();
1394
+
1395
+ /**
1396
+ * <p>Return the current maximum used BDD nodes statistics for this BDD factory.</p>
1397
+ *
1398
+ * @return maximum used BDD nodes statistics
1399
+ */
1400
+ public MaxUsedBddNodesStats getMaxUsedBddNodesStats () {
1401
+ return maxusedbddnodesstats ;
1402
+ }
1403
+
1404
+ /**
1405
+ * Stores continuously statistics about the BDD nodes usage and BDD operations,
1406
+ * where BDD operations is a proxy for time.
1407
+ *
1408
+ * @author mgoorden
1409
+ */
1410
+ public static class ContinuousStats {
1411
+ protected boolean enabled = false ;
1412
+ protected List <Integer > contUsedBddNodes = new ArrayList <Integer >();
1413
+ protected List <Long > contOperations = new ArrayList <Long >();
1414
+
1415
+ protected ContinuousStats () { }
1416
+
1417
+ public void enableMeasurements () {
1418
+ enabled = true ;
1419
+ }
1420
+
1421
+ public void disableMeasurements () {
1422
+ enabled = false ;
1423
+ }
1424
+
1425
+ public void resetMeasurements () {
1426
+ contUsedBddNodes = new ArrayList <Integer >();
1427
+ contOperations = new ArrayList <Long >();
1428
+ }
1429
+
1430
+ public List <Integer > getNodesStats () {
1431
+ if (contUsedBddNodes .size () != contOperations .size ()) {
1432
+ throw new AssertionError ("Incorrect data collection." );
1433
+ }
1434
+ return contUsedBddNodes ;
1435
+ }
1436
+
1437
+ public List <Long > getOperationsStats () {
1438
+ if (contUsedBddNodes .size () != contOperations .size ()) {
1439
+ throw new AssertionError ("Incorrect data collection." );
1440
+ }
1441
+ return contOperations ;
1442
+ }
1443
+ }
1444
+
1445
+ /**
1446
+ * Singleton object for continuous statistics.
1447
+ */
1448
+ protected ContinuousStats continuousstats = new ContinuousStats ();
1449
+
1450
+ /**
1451
+ * <p>Return the current continuous statistics for this BDD factory.</p>
1452
+ *
1453
+ * @return continuous statistics
1454
+ */
1455
+ public ContinuousStats getContinuousStats () {
1456
+ return continuousstats ;
1457
+ }
1458
+
1330
1459
// TODO: bdd_sizeprobe_hook
1331
1460
// TODO: bdd_reorder_probe
1332
1461
0 commit comments