1
0

More than 3 years have passed since last update.

【Java】プログラムの実行時間の計測方法

Posted at

Javaで処理時間を計測するにはミリ秒で計測するcurrentTimeMillisメソッドと、ナノ秒で計測するnanoTimeメソッドがあります。
今回はナノ秒で計測し、秒で出力する方法です。

double start = System.nanoTime();

//計測したい処理を記述

double end = System.nanoTime();
System.out.println("処理時間:" + ((end - start) / Math.pow(10, 9))  + "s");
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0