lagergren@1028: /* lagergren@1028: * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. lagergren@1028: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. lagergren@1028: * lagergren@1028: * This code is free software; you can redistribute it and/or modify it lagergren@1028: * under the terms of the GNU General Public License version 2 only, as lagergren@1028: * published by the Free Software Foundation. lagergren@1028: * lagergren@1028: * This code is distributed in the hope that it will be useful, but WITHOUT lagergren@1028: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or lagergren@1028: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License lagergren@1028: * version 2 for more details (a copy is included in the LICENSE file that lagergren@1028: * accompanied this code). lagergren@1028: * lagergren@1028: * You should have received a copy of the GNU General Public License version lagergren@1028: * 2 along with this work; if not, write to the Free Software Foundation, lagergren@1028: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. lagergren@1028: * lagergren@1028: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA lagergren@1028: * or visit www.oracle.com if you need additional information or have any lagergren@1028: * questions. lagergren@1028: */ lagergren@1028: lagergren@1028: /** lagergren@1028: * Simple benchmark to measure push/pop specialized method performance lagergren@1028: */ lagergren@1028: lagergren@1028: var a = []; lagergren@1028: lagergren@1028: var RESULT = 15; lagergren@1028: lagergren@1028: function bench() { lagergren@1028: var sum = 0; lagergren@1028: for (var i=0;i<10;i++) { lagergren@1028: a.push(i); lagergren@1028: } lagergren@1028: for (var i=0;i<10;i++) { lagergren@1028: sum |= a.pop(); lagergren@1028: } lagergren@1028: return sum; lagergren@1028: } lagergren@1028: lagergren@1028: function runbench() { lagergren@1028: var sum = 0; lagergren@1028: for (var iters = 0; iters<1e8; iters++) { lagergren@1028: sum |= bench(); lagergren@1028: } lagergren@1028: return sum; lagergren@1028: } lagergren@1028: lagergren@1028: var d = new Date; lagergren@1028: var res = runbench(); lagergren@1028: print((new Date - d) + " ms"); lagergren@1028: print(); lagergren@1028: if (res != RESULT) { lagergren@1028: print("ERROR: Wrong result - should be " + RESULT); lagergren@1028: } else { lagergren@1028: print("Verified OK - result is correct"); lagergren@1028: }