public void postIncrementCost(){
LocalTime pre = LocalTime.now();
long start = System.currentTimeMillis();
System.out.println("start postIncremental @==> "+ pre);
int x = Integer.MIN_VALUE;
for(int i=0; i< Integer.MAX_VALUE; i++) {
while (x < Integer.MAX_VALUE) {
x++;
}
x = Integer.MIN_VALUE;
}
LocalTime post = LocalTime.now();
System.out.println("end postIncremental @==> "+ post);
long end = System.currentTimeMillis();
System.out.println("postIncremental consumed @==> "+ (end - start));
}
public void preIncrementCost(){
LocalTime pre = LocalTime.now();
System.out.println("start preIncremental @==> "+ pre);
long start = System.currentTimeMillis();
int x = Integer.MIN_VALUE;
for(int i=0; i< Integer.MAX_VALUE; i++) {
while (x < Integer.MAX_VALUE) {
++x;
}
x = Integer.MIN_VALUE;
}
LocalTime post = LocalTime.now();
System.out.println("end preIncremental @==> "+ post);
long end = System.currentTimeMillis();
System.out.println("preIncremental consumed @==> "+ (end - start));
}
public void mathIncrementCost(){
LocalTime pre = LocalTime.now();
System.out.println("start mathIncremental @==> "+ pre);
long start = System.currentTimeMillis();
int x = Integer.MIN_VALUE;
for(int i=0; i< Integer.MAX_VALUE; i++) {
while (x < Integer.MAX_VALUE) {
x = x+1;
}
x = Integer.MIN_VALUE;
}
LocalTime post = LocalTime.now();
System.out.println("end mathIncremental @==> "+ post);
long end = System.currentTimeMillis();
System.out.println("mathIncremental consumed @==> "+ (end - start));
}
start postIncremental @==> 15:47:41.764
end postIncremental @==> 15:47:41.773
postIncremental consumed @==> 9
start preIncremental @==> 15:47:41.774
end preIncremental @==> 15:47:41.782
preIncremental consumed @==> 8
start mathIncremental @==> 15:47:41.782
end mathIncremental @==> 15:47:41.791
mathIncremental consumed @==> 9