Exemple #1
0
 public string GetReport()
 {
     ComputeStats();
     var w = new StringWriter();
     using (w.Tag("table"))
     {
         w.WriteLine("<tr><td>benchmark</td><td colspan={0}>runs</td><td>relative</td><td>ops / second</tr>".Formatted(operationruns.First().Value.Runs.Count));
         foreach (var run in this.operationruns)
         {
             w.WriteLine("<tr><td>{0}</td>{1}<td>{2}</td><td>{3}</td></tr>".Formatted(
                 run.Key,
                 run.Value.Runs.Select(r => "<td align=right>{0}</td>".Formatted(r.ExecutionTime.TotalMilliseconds.ToString("0.00"))).Joined(),
                 "<div class='bar' style='width:{0}px'>&nbsp;</div>".Formatted(run.Value.RelativeExecutionTimePercent),
                 run.Value.AverageOperationsPerSeconds(this.N).ToString("#,##0")
                 ));
         }
     }
     w.WriteLine();
     using (w.Tag("table"))
     {
         w.TableRow("computer specs");
         var spec = new ComputerSpecs();
         foreach (FieldInfo field in spec.GetType().GetFields())
         {
             w.TableRow(field.Name, field.GetValue(spec) as string);
         }
     }
     string html = File.ReadAllText("results.htm");
     html = html.Replace("results", w.ToString());
     return html;
 }