0
Is it possible to print a line for 1000 times per second?
Is it possible to print a line for 1000 times per second? For example : Print the Hello World for 1000 times per second. I have a doubt in this. Answer for this and give code.
6 Respuestas
+ 2
It depends up on the processor of your mobile,computer or laptop.
+ 2
Here is the code
public class HelloWorld {
public static void main(String args[])
{
long startTime = System.nanoTime();
for(int i=0;i<200000;i++) {
System.out.println("Hello world\n");
}
long stopTime = System.nanoTime();
System.out.println((stopTime - startTime)/1000000000.0);
}
}
+ 1
Yes you can
As I tried
It say that 10000 line can be printed in 0.98 second
+ 1
I have tried in javascript and it depends on hardware of device
And I will try in Java now
This is the code
var t0 = performance.now();
function doSomething(){
for(var i=0;i<10000;i++){
console.log("Hello world");
}
}
doSomething();
var t1 = performance.now()
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")
+ 1
Wow
+ 1
200000 line / second
And again it's depending on hardware