1 19 package gnu.trove.benchmark; 20 21 import java.io.*; 22 23 30 31 class XMLReporter implements Reporter { 32 PrintWriter out; 33 34 XMLReporter() { 35 this.out = new PrintWriter(new OutputStreamWriter(System.out), 36 true); 37 } 38 39 XMLReporter(PrintWriter out) { 40 this.out = out; 41 } 42 43 public void report(Result result) { 44 out.println("<result>"); 45 out.print("<desc>"); 46 out.print(result.getDescription()); 47 out.println("</desc>"); 48 49 out.print("<iterations>"); 50 out.print(result.getIterations()); 51 out.println("</iterations>"); 52 53 out.print("<theirTotal>"); 54 out.print(result.getTheirs()); 55 out.println("</theirTotal>"); 56 57 out.print("<theirAvg>"); 58 out.print(result.getTheirAvg()); 59 out.println("</theirAvg>"); 60 61 out.print("<ourTotal>"); 62 out.print(result.getOurs()); 63 out.println("</ourTotal>"); 64 65 out.print("<ourAvg>"); 66 out.print(result.getOurAvg()); 67 out.println("</ourAvg>"); 68 69 out.println("</result>"); 70 } 71 72 public void start() { 73 out.println("<?xml version=\"1.0\" encoding=\"ASCII\" ?>"); 74 out.println("<benchmark>"); 75 out.print("<env>"); 76 for (int i = 0; i < ENV_PROPS.length; i++) { 77 String key = ENV_PROPS[i]; 78 out.print(System.getProperty(key)); 79 out.print(" "); 80 } 81 out.println("</env>"); 82 } 83 84 public void finish() { 85 out.println("</benchmark>"); 86 } 87 } 88 | Popular Tags |