Repository navigation
Expand file tree
/
Copy pathstringFormatBenchmarks.htm
More file actions
151 lines (120 loc) · 4.2 KB
/
Copy pathstringFormatBenchmarks.htm
File metadata and controls
151 lines (120 loc) · 4.2 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="Scripts/google-spreadsheet.js" type="text/javascript"></script>
<script src="Scripts/google-spreadsheet-parser.js" type="text/javascript"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<br />
<div id="GraphContainer">
</div>
<script type="text/javascript">
//container: div container
//type: 'line' for example
//title: 'Dictionary Benchmarks'
//categories: array of x-graph
//ytitle: y graph title
function DrawChart(container, type, title, categories, ytitle, series)
{
var chart = new Highcharts.Chart({
chart: {
renderTo: container,
type: type,
marginRight: 130,
marginBottom: 25
},
title: {
text: title,
x: -20 //center
},
// subtitle: {
// text: 'Source: WorldClimate.com',
// x: -20
// },
xAxis: {
categories: categories
},
yAxis: {
title: {
text: ytitle
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function ()
{
return '<b>' + this.series.name + '</b><br/>' +
this.x + ': ' + this.y + '';
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: series
});
return chart;
}
function ChartFromDictionaryData(container, sparser, rows, title, ytitle)
{
//need to do read / write / only
//get all dictionary types
var serieslist = sparser.DistinctByColumn(rows, "FormatMethod");
delete serieslist["FormatMethod"];
//get all threads
var threads = sparser.DistinctByColumn(rows, "ParameterCount");
delete threads["ParameterCount"];
//highcharts categories
var categories = [];
for (var thread in threads)
{
categories.push(parseInt(thread));
}
categories.sort(function (a, b) { return a - b; });
//foreach dictionary, get all rows, order by threads, get timing
var highchartseries = [];
for (var series in serieslist)
{
var newseries = {};
newseries.name = series;
newseries.data = [];
var rowdata = sparser.FilterByColumn(rows, "FormatMethod", series);
for (var thread in threads)
{
var rowvalue = parseInt(sparser.GetValue(sparser.FilterByColumn(rowdata, "ParameterCount", thread), "Time"));
newseries.data.push(rowvalue);
}
highchartseries.push(newseries);
}
DrawChart(container, "line", title, categories, ytitle, highchartseries);
}
localStorage.clear();
var url = "https://docs.google.com/spreadsheet/pub?key=0Akqqf0SS9IbJdDVJdUI4ckJnaVdaQkdKMWJFeXNXLVE&output=html";
var googleSpreadsheet = new GoogleSpreadsheet();
googleSpreadsheet.url(url);
googleSpreadsheet.load(function (result)
{
try
{
var sparser = new GoogleSpreadsheetParser(result);
ChartFromDictionaryData('GraphContainer', sparser, sparser.GetAllRows(), "string.Format Benchmarks", "Time (ms) per 100,000 operations");
//$('#results').html(JSON.stringify(result).replace(/,/g, ",\n"));
} catch (e)
{
alert(e);
}
});
</script>
</body>
</html>