01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.emultest.java.util;
17:
18: import com.google.gwt.user.client.ui.WidgetProfile;
19:
20: import java.util.Stack;
21:
22: /**
23: * TODO: document me.
24: */
25: public class StackProfile extends WidgetProfile {
26:
27: /**
28: * Sets module name so that javascript compiler can operate
29: */
30: public String getModuleName() {
31: return "com.google.gwt.emultest.EmulSuite";
32: }
33:
34: public void testTiming() throws Exception {
35: int t = 1;
36: while (true) {
37: testTiming(t);
38: t = t * 2;
39: }
40: // throw new Exception("Finished profiling");
41: }
42:
43: public void testTiming(int i) {
44: addTiming(i);
45: }
46:
47: public void addTiming(int num) {
48: Stack s = new Stack();
49: resetTimer();
50: for (int i = 0; i < num; i++) {
51: s.push("item" + i);
52: }
53: timing("push(" + num + ")");
54: resetTimer();
55: for (int i = 0; i < num; i++) {
56: s.pop();
57: }
58: timing("pop(" + num + ")");
59: }
60: }
|