我用两个文件创建了一个 csv 文件。我想为用户提供一个输入数字的机会,以便程序重复创建 csv 文件的过程。
因此,如果用户输入 5,例如程序重复该过程 5 次并打印出执行该过程所花费的时间。
重复处理部分
int Numofrepetition;
Scanner getin = new Scanner (System.in);
System.out.println("How many times you want to repeate the process");
Numofrepetition =getin.nexLine();
Using
Long t0 = System.currentTimeMillis ();
System.out.println((System.currentTimeMillis()-t0)/1000.0);
最佳答案
Long t0 = System.currentTimeMillis ();
for(int i=0;i<Numofrepetition;i++){
//TODO creating the csv file
}
System.out.println((System.currentTimeMillis()-t0)/1000.0);
循环就是为此而制作的
关于JAVA 在java中重复一个过程并计算所花费的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41191917/