summaryrefslogtreecommitdiffstats
path: root/dx/tests/131-perf/ClassGen.java
blob: c35bbcf82e430120cc13f1c5668109ebb0299248 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.io.File;
import java.io.PrintWriter;

public class ClassGen {

    public static void main(String... args) {

	int start = 1;
        int end =   8024;
	int fields =   4;
        int methods =   6;
	if (args.length > 0) {
	    start = Integer.parseInt(args[0]);
        }
	if (args.length > 1) {
	    end = Integer.parseInt(args[1]);
        }
	if (args.length > 2) {
	    fields = Integer.parseInt(args[2]);
        }
	if (args.length > 3) {
	    methods = Integer.parseInt(args[3]);
        }

	for (int file = start; file <= end; file++) {
            try {
	        File f = new File("src/Clazz" + file + ".java");
	        PrintWriter pw = new PrintWriter(f);
		pw.println("class Clazz" + file + " {");
		for (int field = 1; field <= fields; field++) {
		    pw.println("    public static int f" + field + ";");
		}
		for (int method = 1; method <= methods; method++) {
		    pw.println("    boolean m" + method + "_" + (file%(end/2)) + "() {"
);
		    pw.println("      int max = Thread.MAX_PRIORITY;");
		    pw.println("      for (int i = 0; i < max; i++) {");
		    pw.println("        System.out.println(\"Hello from: \" + Clazz"
                            + file + ".class + \".method" + method
                            + "() \" + Clazz" + (end-file+1) + ".f1);");
		    pw.println("        Thread.dumpStack();");
		    pw.println("      }");
		    pw.println("      return Thread.holdsLock(this);");
		    pw.println("    }");
		}
		pw.println("}");
                pw.close();
            } catch(Exception ex) {
		System.out.println("Ups");
            }
        }
    }
}