aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/js
diff options
context:
space:
mode:
authorPeter Wu2014-07-26 01:24:22 +0200
committerPim van den Berg2014-08-02 12:29:42 +0200
commit5a2357e551abe61cda4bf22019ea229d8ed0fb02 (patch)
tree27bfe1ec2dbe70cf62aa7c4178a2bc170fa74183 /js
parentjsrrdgraph: binaryXHR: jshint style fixes (diff)
downloadapt-panopticon_cgp-5a2357e551abe61cda4bf22019ea229d8ed0fb02.zip
apt-panopticon_cgp-5a2357e551abe61cda4bf22019ea229d8ed0fb02.tar.gz
apt-panopticon_cgp-5a2357e551abe61cda4bf22019ea229d8ed0fb02.tar.bz2
apt-panopticon_cgp-5a2357e551abe61cda4bf22019ea229d8ed0fb02.tar.xz
jsrrdgraph: Performance fix
commit 2a74a333ff143499b465234f0395a4aad7bdaa78 ("Upgrade to javascriptrrd ver 1.1.1") converted getByteAt calls to a getEndianByteAt call, but this also introduced a branch operation. Since endianess is dependent on the file, we can move the switch_endian check outside the function. Performance improved from 0.148ms (n=336k) to .039ms (n=384k) which translates to about 30 seconds!
Diffstat (limited to 'js')
-rw-r--r--js/binaryXHR.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/js/binaryXHR.js b/js/binaryXHR.js
index 63186b3..6749273 100644
--- a/js/binaryXHR.js
+++ b/js/binaryXHR.js
@@ -63,12 +63,15 @@ function BinaryFile(strData, iDataOffset, iDataLength) {
63 throw new InvalidBinaryFile("Unsupported type " + (typeof strData)); 63 throw new InvalidBinaryFile("Unsupported type " + (typeof strData));
64 } 64 }
65 65
66 this.getEndianByteAt = function(iOffset,width,delta) { 66 if (switch_endian) {
67 if (this.switch_endian) 67 this.getEndianByteAt = function(iOffset, width, delta) {
68 return this.getByteAt(iOffset+width-delta-1); 68 return this.getByteAt(iOffset + width - delta - 1);
69 else 69 };
70 return this.getByteAt(iOffset+delta); 70 } else {
71 }; 71 this.getEndianByteAt = function(iOffset, width, delta) {
72 return this.getByteAt(iOffset + delta);
73 };
74 }
72 75
73 this.getLength = function() { 76 this.getLength = function() {
74 return dataLength; 77 return dataLength;