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.

5th May 2020, 6:18 AM
🐕Pradeep Simba 🐶
🐕Pradeep Simba 🐶 - avatar
6 ответов
+ 2
It depends up on the processor of your mobile,computer or laptop.
5th May 2020, 6:38 AM
Dasarath Singh
+ 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); } }
5th May 2020, 7:25 AM
ycsvenom
ycsvenom - avatar
+ 1
Yes you can As I tried It say that 10000 line can be printed in 0.98 second
5th May 2020, 6:50 AM
ycsvenom
ycsvenom - avatar
+ 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.")
5th May 2020, 6:56 AM
ycsvenom
ycsvenom - avatar
+ 1
Wow
5th May 2020, 7:24 AM
ycsvenom
ycsvenom - avatar
+ 1
200000 line / second And again it's depending on hardware
5th May 2020, 7:24 AM
ycsvenom
ycsvenom - avatar