test_propertycache.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7  POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 , USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
31 function runTest () {
32  runPerfTest("propertycache full get", perfTest);
33  runPerfTest("propertycache chunked get", perfTest2);
34 }
35 
36 function perfTest(library, timer) {
37 
38  // Get all the guids
39  var guidList = [];
40  library.enumerateAllItems({
41  onEnumerationBegin: function(list) {
42  return Ci.sbIMediaListEnumerationListener.CONTINUE;
43  },
44  onEnumeratedItem: function(list, item) {
45  guidList.push(item.guid);
46  return Ci.sbIMediaListEnumerationListener.CONTINUE;
47  },
48  onEnumerationEnd: function(list, status) {
49  }
50  });
51 
52  var cache = library.QueryInterface(Ci.sbILocalDatabaseLibrary).propertyCache;
53 
54  // Record time to cache all properties
55  timer.start();
56 
57  var bagCount = {};
58  var bags = cache.getProperties(guidList, guidList.length, bagCount);
59 
60  timer.stop();
61 }
62 
63 function perfTest2(library, timer) {
64 
65  // Get all the guids
66  var guidList = [];
67  library.enumerateAllItems({
68  onEnumerationBegin: function(list) {
69  return Ci.sbIMediaListEnumerationListener.CONTINUE;
70  },
71  onEnumeratedItem: function(list, item) {
72  guidList.push(item.guid);
73  return Ci.sbIMediaListEnumerationListener.CONTINUE;
74  },
75  onEnumerationEnd: function(list, status) {
76  }
77  });
78 
79  var cache = library.QueryInterface(Ci.sbILocalDatabaseLibrary).propertyCache;
80 
81  // Record time to cache all properties
82  timer.start();
83 
84  for (var i = 0; i < (guidList.length - (guidList.length%200)); i += 200) {
85  var bagCount = {};
86  var bags = cache.getProperties(guidList.slice(i, i+200), 200, bagCount);
87  }
88 
89  timer.stop();
90 }
function runPerfTest(aName, aTestFunc)
function perfTest2(library, timer)
function runTest()
Test file.
const Ci
function perfTest(library, timer)
_getSelectedPageStyle s i