]> git.parisson.com Git - pdf.js.git/commitdiff
Added dumb profiling instrumentation
authorChris Jones <jones.chris.g@gmail.com>
Thu, 5 May 2011 02:39:07 +0000 (21:39 -0500)
committerChris Jones <jones.chris.g@gmail.com>
Thu, 5 May 2011 02:39:07 +0000 (21:39 -0500)
test.html

index 22e9101d29ab3e1848f85d6cdae12679e00f4ad4..16bedf93da6b92a3098f665f755361a06a55830d 100644 (file)
--- a/test.html
+++ b/test.html
@@ -43,6 +43,19 @@ function prevPage() {
     pageNum = (pageNum - 1 + numPages) % numPages;
     displayPage(pageNum);
 }
+
+function profile() {
+    const NUM_TRIALS = 10000;
+    var start = Date.now();
+    for (var i = 0; i < NUM_TRIALS; ++i)
+        displayPage(pageNum);
+    var end = Date.now();
+    var elapsed = (end - start);
+
+    alert("Drawing current page "+ NUM_TRIALS +" times took "+
+          (elapsed / 1000.0) +" seconds, "+
+          "~"+ (elapsed / NUM_TRIALS) +" ms/draw (totally unscientific)");
+}
   </script>
 </head>
 
@@ -51,6 +64,7 @@ function prevPage() {
     <button onclick="prevPage();">Previous</button>
     <input type="text" id="pageNumber" value="0"></input>
     <button onclick="nextPage();">Next</button>
+    <button onclick="profile();">Profile</button>
   <div id="viewer">
     <!-- Canvas dimensions must be specified in CSS pixels.  CSS pixels
       -- are always 96 dpi.  These dimensions are 8.5x11in at 96dpi. -->