Update of /cvsroot/jrobin/src
In directory sc8-pr-cvs1:/tmp/cvs-serv5669
Modified Files:
Demo.java
Log Message:
Related classes (RrdInt, RrdLong, etc) are now properly rooted. RrdPrimtive class introduced as a base class for all classes mapped to a RRD file. Code should run slightly faster.
Index: Demo.java
===================================================================
RCS file: /cvsroot/jrobin/src/Demo.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Demo.java 17 Nov 2003 08:09:41 -0000 1.7
--- Demo.java 27 Nov 2003 10:22:58 -0000 1.8
***************
*** 33,42 ****
--- 33,48 ----
import java.io.IOException;
import java.io.PrintWriter;
+ import java.util.Random;
class Demo {
+ static final long SEED = 1909752002L;
+
+ static final Random RANDOM = new Random(SEED);
static final String HOME = Util.getJRobinDemoDirectory();
static final String FILE = "demo";
+
static final long START = Util.getTimestamp(2003, 4, 1);
static final long END = Util.getTimestamp(2003, 5, 1);
+
static final int MAX_STEP = 300;
***************
*** 76,80 ****
pw.println(rrdDef.dump());
RrdDb rrdDb = new RrdDb(rrdDef);
! println("== RRD file created.");
// update database
--- 82,87 ----
pw.println(rrdDef.dump());
RrdDb rrdDb = new RrdDb(rrdDef);
! rrdDb.close();
! println("== RRD file created and closed.");
// update database
***************
*** 84,87 ****
--- 91,95 ----
MAX_STEP + " seconds (* denotes 1000 updates)");
long t = start; int n = 0;
+ rrdDb = new RrdDb(rrdPath);
Sample sample = rrdDb.createSample();
while(t <= end + 86400L) {
***************
*** 92,96 ****
sample.update();
! t += Math.random() * MAX_STEP + 1;
if(((++n) % 1000) == 0) {
System.out.print("*");
--- 100,104 ----
sample.update();
! t += RANDOM.nextDouble() * MAX_STEP + 1;
if(((++n) % 1000) == 0) {
System.out.print("*");
***************
*** 180,185 ****
long getValue() {
double oldValue = value;
! double increment = Math.random() * step;
! if(Math.random() > 0.5) {
increment *= -1;
}
--- 188,193 ----
long getValue() {
double oldValue = value;
! double increment = Demo.RANDOM.nextDouble() * step;
! if(Demo.RANDOM.nextDouble() > 0.5) {
increment *= -1;
}
|