1 /*
2  * @(#) $Id: PerfTest.java,v 1.2 2003/07/08 08:13:52 pankaj Exp $
3  *
4  * Copyright (c) 2002-03 by Pankaj Kumar (http://www.pankaj-k.net). 
5  * All rights reserved.
6  *
7  * The license governing the use of this file can be found in the 
8  * root directory of the containing software.
9  */
10import java.io.*;
11
12public class PerfTest {
13    public static int count = 1000000;
14    public static String PROP = "user.dir";
15
16    public static String getsysprop(String prop){
17        return System.getProperty(prop);
18    }
19    public static void main(String[] args) throws IOException {
20        if (args.length > 0){
21            count = Integer.parseInt(args[0]);
22        }
23        System.out.println(PROP + " = " + getsysprop(PROP));
24        String pv = null;
25        for (int r = 0; r < 4; r++){    // Many rounds.
26            long ts = System.currentTimeMillis();
27            for (int l = 0; l < count; l++){
28                pv = getsysprop(PROP);
29            }
30            long te = System.currentTimeMillis();
31            System.out.println("Round[" + r + "], Elapsed time for " + count + " iterations: " +
32                (te - ts) + " milli secs.");
33        }
34    }
35}