Skip to content

Instantly share code, notes, and snippets.

@neetsdkasu
Last active October 9, 2016 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neetsdkasu/94e7ffec84cc51a81a3a1737aff0bc63 to your computer and use it in GitHub Desktop.
Save neetsdkasu/94e7ffec84cc51a81a3a1737aff0bc63 to your computer and use it in GitHub Desktop.
実行時間計測 (雑) (キョープロ関係で使う) (Windows上で使う)
// 実行時間計測
// license: public domain
// author: Leonardone @ NEETSDKASU
//
// usage:
// java Time command args..
//
// e.g.
// java Time java -cp Problem1 Solver < .\Problem1\TestCase1.txt > .\Problem1\Answer1.txt
//
public class Time
{
public static void main(String[] args) throws Exception
{
if (args.length == 0)
{
System.err.println("no command");
System.exit(1);
return;
}
ProcessBuilder pb = new ProcessBuilder(args);
pb.inheritIO();
long time1, time2;
time1 = System.currentTimeMillis();
Process proc = pb.start();
proc.waitFor();
if (proc.exitValue() != 0)
{
System.exit(proc.exitValue());
return;
}
time2 = System.currentTimeMillis();
System.err.println("----------");
System.err.println("time1: " + Long.toString(time1));
System.err.println("time2: " + Long.toString(time2));
System.err.println("diff:" + Long.toString(time2 - time1));
}
}
@neetsdkasu
Copy link
Author

Linuxにはちゃんと実行時間計測用のコマンドがあるらしい

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment