-
Notifications
You must be signed in to change notification settings - Fork 191
/
perftest.js
156 lines (109 loc) · 4.01 KB
/
perftest.js
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
//GLMol performance tests
$(document).ready(function() {
glviewer = new GLmol("gldiv", true);
//starts QUnit tests
start();
});
var resultXML = null;
var resultStr = "";
var profile = QUnit.urlParams.profilecheck;
//QUnit-reporter hook to output test results in XML format
QUnit.jUnitReport = function(data) {
resultXML = $.parseXML(data.xml);
//Wrap XML result in JQuery object; parse and setup output string
$result = $(resultXML);
resultStr += "GLMol Performance Tests\n";
var runTime = $result.find("testsuites").attr("time");
var runDate = $result.find("testsuites").attr("timestamp");
resultStr += "Total Test Time: " + runTime + " s\n";
resultStr += "Date: " + runDate + "\n\n";
$result.find("testsuite").each(function(){
var moduleName = $(this).attr("name");
var moduleTime = $(this).attr("time");
resultStr += "\n" + moduleName;
//alert(moduleName);
$(this).find("testcase").each(function() {
var testName = $(this).attr("name");
var testTime = $(this).attr("time");
resultStr += "\n\t" + testName + ": " + testTime + " s";
//alert(testName);
});
resultStr += "\n\tTotal: " + moduleTime + " s\n";
});
//Set up a link to download test results
$("#qunit-testresult").append("<br><a id='download'>Download</a>");
var url = "data:text/plain;charset=utf-8," + encodeURIComponent(resultStr);
$("#download").attr("download", "webgltest.log");
$("#download").attr("href", url);
//alert(resultStr);
};
var styleSpec = ["stick", "line", "cross", "sphere", "cartoon"];
var defineRep = function(style) {
return function() {
var all = this.getAllAtoms();
var target = this.modelGroup;
if (style === 'stick')
this.drawBondsAsStick(target, all, this.cylinderRadius, this.cylinderRadius, true);
else if (style === 'line')
this.drawBondsAsLine(target, all, this.lineWidth);
else if (style === 'cross')
this.drawAsCross(target, all, 0.3, true);
else if (style === 'sphere')
this.drawAtomsAsSphere(target, all, this.sphereRadius);
else if (style === 'cartoon') {
this.colorChainbow(all);
this.drawCartoon(target, all, false, this.thickness);
}
};
};
//Generic style render testcase
var testcase = function(styleType, profile) {
var testName = styleType + " render";
var timeName = styleType + " render time: ";
var testMsg = styleType + " style set correctly";
test(testName, function() {
console.group(testName);
console.time(timeName);
if (profile)
console.profile();
glviewer.defineRepresentation = defineRep(styleType);
glviewer.rebuildScene();
glviewer.show();
if (profile)
console.profileEnd();
console.timeEnd(timeName);
console.groupEnd();
ok(true, testMsg);
});
};
var runtests = (function(profile) {
for (var style in styleSpec)
new testcase(styleSpec[style], profile);
});
//test cases
//TESTS
//moldata 3
QUnit.module( "C. Calicivirus Capsid, 12,362 atoms (3M8L)", {
setupOnce: function() {
stop();
$.get("test_structs/3M8L.pdb", function(data) {
//glviewer.loadMoleculeStr(false, data);
glviewer.protein = {sheet: [], helix: [], biomtChains: '', biomtMatrices: [], symMat: [], pdbID: '', title: ''};
glviewer.atoms = [];
glviewer.parsePDB2(data);
var all = glviewer.getAllAtoms();
glviewer.colorByAtom(all, {});
glviewer.initializeScene();
glviewer.setBackground(0xffffff);
glviewer.zoomInto(glviewer.getAllAtoms());
start();
}, "text");
console.groupEnd();
console.group("Capsid (12,362 atoms)");
},
teardownOnce: function() {
console.groupEnd();
//glviewer.removeAllModels();
}
});
runtests(profile);