Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why is printing “B” slower than printing “#”?

Name: Anonymous 2016-09-08 14:01

http://stackoverflow.com/questions/21947452/why-is-printing-b-dramatically-slower-than-printing?noredirect=1&lq=1

Random r = new Random();
for (int i = 0; i < 1000; i++) {
for (int j = 0; j < 1000; j++) {
if(r.nextInt(4) == 0) {
System.out.print("O");
} else {
System.out.print("#");
}
}

System.out.println("");
}


Random r = new Random();
for (int i = 0; i < 1000; i++) {
for (int j = 0; j < 1000; j++) {
if(r.nextInt(4) == 0) {
System.out.print("O");
} else {
System.out.print("B"); //only line changed
}
}

System.out.println("");
}


Using the code, the first matrix took 8.52 seconds to complete
With this code, the second matrix took 259.152 seconds to complete

Name: Anonymous 2016-09-08 14:47

Java
found the answer.

Name: Anonymous 2016-09-08 14:54

>>2
thats incorrect

Name: Anonymous 2016-09-08 15:25

>>1
First matrix ran for 48 seconds on my machine before I had to force-quit to prevent my CPU from overheating.

Name: Anonymous 2016-09-08 18:27

Because "B" has more pixels.

Name: Anonymous 2016-09-08 18:55

>>5
good guess but no!

Name: Anonymous 2016-09-10 2:59

Because God made it that way. Checkmate atheists.

Name: Anonymous 2016-09-11 8:45

Running in emacs on my machine "#" takes 6.9 seconds while "B" takes 6.1 seconds.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List