1 37 package org.jfree.chart.demo; 38 39 import java.awt.geom.Line2D ; 40 import java.util.Date ; 41 42 47 public class Performance { 48 49 50 private double value = 2.0; 51 52 53 private Double number = new Double (value); 54 55 58 public Performance() { 59 } 60 61 66 public void createLines(int count) { 67 68 Line2D line = new Line2D.Double (); 69 for (int i = 0; i < count; i++) { 70 line = new Line2D.Double (1.0, 1.0, 1.0, 1.0); 71 } 72 System.out.println(line.toString()); 73 74 } 75 76 81 public void setLines(int count) { 82 83 Line2D line = new Line2D.Double (0.0, 0.0, 0.0, 0.0); 84 for (int i = 0; i < count; i++) { 85 line.setLine(1.0, 1.0, 1.0, 1.0); 86 } 87 88 } 89 90 95 public void getNumber(int count) { 96 97 double d = 0.0; 98 for (int i = 0; i < count; i++) { 99 d = this.number.doubleValue(); 100 } 101 System.out.println(d); 102 103 } 104 105 110 public void getValue(int count) { 111 112 double d = 0.0; 113 for (int i = 0; i < count; i++) { 114 d = this.value; 115 } 116 System.out.println(d); 117 118 } 119 120 126 public void writeTime(String text, Date time) { 127 128 System.out.println(text + " : " + time.getTime()); 129 130 } 131 132 137 public static void main(String [] args) { 138 139 Performance p = new Performance(); 140 System.out.println("Simple performance tests."); 141 142 Date start1 = new Date (); 143 p.createLines(100000); 144 Date end1 = new Date (); 145 146 Date start2 = new Date (); 147 p.setLines(100000); 148 Date end2 = new Date (); 149 150 p.writeTime("Start create lines", start1); 151 p.writeTime("Finish create lines", end1); 152 p.writeTime("Start set lines", start2); 153 p.writeTime("Finish set lines", end2); 154 155 Date start3 = new Date (); 156 p.getNumber(1000000); 157 Date end3 = new Date (); 158 159 Date start4 = new Date (); 160 p.getValue(1000000); 161 Date end4 = new Date (); 162 163 p.writeTime("Start get number", start3); 164 p.writeTime("Finish get number", end3); 165 p.writeTime("Start get value", start4); 166 p.writeTime("Finish get value", end4); 167 168 169 } 170 171 } 172 | Popular Tags |