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.user.client.ui;
17:
18: import java.util.Map;
19:
20: /**
21: * TODO: document me.
22: */
23: public class FastStringMapProfile extends WidgetProfile {
24:
25: Map m;
26:
27: public void testTiming() throws Exception {
28: m = putTiming(32000);
29: timing(2000);
30: timing(4000);
31: timing(8000);
32: timing(16000);
33: timing(32000);
34: throw new Exception("|browser|test case|time|");
35: }
36:
37: private void timing(int s) {
38: getTiming(s);
39: }
40:
41: public void getTiming(int size) {
42: this .resetTimer();
43: for (int i = 0; i < size; i++) {
44: m.get(size + ":");
45: }
46: this .timing("get(" + size + ")");
47: }
48:
49: public FastStringMap putTiming(int size) {
50: FastStringMap m1 = new FastStringMap();
51: this .resetTimer();
52: for (int i = 0; i < size; i++) {
53: Integer iVal = new Integer(size);
54: m1.put(iVal.hashCode() + "", iVal);
55: }
56: this .timing("put(" + size + ")");
57: return m1;
58: }
59:
60: public int instanceOfTiming() {
61: int count = 0;
62: int size = 20000;
63: Object a = new String();
64:
65: this .resetTimer();
66: for (int i = 0; i < size; i++) {
67: if (a instanceof String) {
68: ++count;
69: }
70: }
71: this .timing("instanceOf(" + size + "," + a + ")");
72: return count;
73: }
74: }
|