简体   繁体   English

对文件进行读写操作的次数

[英]times the read & write operations for a file

i am trying to find a way to Create a class and associated methods that times the read / write operations, displaying the results to the console.我试图找到一种方法来创建一个类和关联的方法来计时读/写操作,将结果显示到控制台。 i looked everywhere but i didnt find any thing (( is it possible to do it ? if so , how ?我到处找,但我没有找到任何东西((有可能做到吗?如果有,怎么做?

You could try this :你可以试试这个:

long readMethodStartTime = System.nanoTime();
readMethod();
long readMethodEndTime = System.nanoTime();

long readMethodDuration = readMethodEndTime - readMethodStartTime ;
System.out.println("Time taken for readMethod to execute: " + readMethodDuration);

and similarly for write methods.和类似的写方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM