Last active
October 9, 2016 20:50
-
-
Save neetsdkasu/94e7ffec84cc51a81a3a1737aff0bc63 to your computer and use it in GitHub Desktop.
実行時間計測 (雑) (キョープロ関係で使う) (Windows上で使う)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 実行時間計測 | |
// 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)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Linuxにはちゃんと実行時間計測用のコマンドがあるらしい