feat(benchmark): add a simple benchmark for the di module

This commit is contained in:
vsavkin
2014-10-08 16:15:38 -04:00
parent 035dc5ba44
commit 1f4caa8773
12 changed files with 298 additions and 28 deletions

View File

@ -1,5 +1,5 @@
import {MapWrapper} from 'facade/collection';
import {FIELD, int} from 'facade/lang';
import {FIELD, int, isPresent} from 'facade/lang';
var _allKeys = {};
var _id:int = 0;
@ -15,9 +15,8 @@ export class Key {
static get(token) {
if (token instanceof Key) return token;
if (MapWrapper.contains(_allKeys, token)) {
return MapWrapper.get(_allKeys, token)
}
var obj = MapWrapper.get(_allKeys, token);
if (isPresent(obj)) return obj;
var newKey = new Key(token, ++_id);
MapWrapper.set(_allKeys, token, newKey);