fix benchmarks

This commit is contained in:
vsavkin 2015-10-08 09:57:10 -07:00
parent 8b725c77fd
commit d63f3c123e
17 changed files with 36 additions and 57 deletions

View File

@ -255,30 +255,26 @@ export class Binding {
* expect(injector.get('message')).toEqual('Hello');
* ```
*/
export abstract class ResolvedBinding {
export interface ResolvedBinding {
/**
* A key, usually a `Type`.
*/
public key: Key;
key: Key;
/**
* Factory function which can return an instance of an object represented by a key.
*/
public resolvedFactories: ResolvedFactory[];
resolvedFactories: ResolvedFactory[];
/**
* Indicates if the binding is a multi-binding or a regular binding.
*/
public multiBinding: boolean;
multiBinding: boolean;
}
export class ResolvedBinding_ extends ResolvedBinding {
constructor(key: Key, resolvedFactories: ResolvedFactory[], multiBinding: boolean) {
super();
this.key = key;
this.resolvedFactories = resolvedFactories;
this.multiBinding = multiBinding;
}
export class ResolvedBinding_ implements ResolvedBinding {
constructor(public key: Key, public resolvedFactories: ResolvedFactory[],
public multiBinding: boolean) {}
get resolvedFactory(): ResolvedFactory { return this.resolvedFactories[0]; }
}

View File

@ -134,17 +134,7 @@ export class CyclicDependencyError extends AbstractBindingError {
* }
* ```
*/
export abstract class InstantiationError extends WrappedException {
constructor(message, originalException, originalStack, context) {
super(message, originalException, originalStack, context);
}
abstract addKey(injector: Injector, key: Key): void;
get wrapperMessage(): string { return unimplemented(); };
get causeKey(): Key { return unimplemented(); };
get context() { return unimplemented(); };
}
export class InstantiationError_ extends InstantiationError {
export class InstantiationError extends WrappedException {
/** @internal */
keys: Key[];

View File

@ -13,7 +13,6 @@ import {
NoBindingError,
CyclicDependencyError,
InstantiationError,
InstantiationError_,
InvalidBindingError,
OutOfBoundsError,
MixingMultiBindingsWithRegularBindings
@ -866,7 +865,7 @@ export class Injector {
break;
}
} catch (e) {
throw new InstantiationError_(this, e, e.stack, binding.key);
throw new InstantiationError(this, e, e.stack, binding.key);
}
return obj;
}

View File

@ -2,7 +2,6 @@ import {isPresent, isString, StringWrapper, isBlank} from 'angular2/src/core/fac
import {DoCheck, OnDestroy} from 'angular2/lifecycle_hooks';
import {Directive} from 'angular2/src/core/metadata';
import {ElementRef} from 'angular2/src/core/linker';
import {ElementRef_} from '../linker/element_ref';
import {
IterableDiffer,
IterableDiffers,

View File

@ -7,7 +7,6 @@ import {ElementRef} from 'angular2/src/core/linker';
import {Directive} from 'angular2/src/core/metadata';
import {Renderer} from 'angular2/src/core/render';
import {isPresent, isBlank, print} from 'angular2/src/core/facade/lang';
import {ElementRef_} from "../linker/element_ref";
/**
* The `NgStyle` directive changes styles based on a result of expression evaluation.

View File

@ -14,6 +14,14 @@ import {ViewRef, HostViewRef} from './view_ref';
* method.
*/
export abstract class ComponentRef {
/**
* The injector provided {@link DynamicComponentLoader#loadAsRoot}.
*
* TODO(i): this api is useless and should be replaced by an injector retrieved from
* the HostElementRef, which is currently not possible.
*/
injector: Injector;
/**
* Location of the Host Element of this Component Instance.
*/
@ -54,14 +62,6 @@ export abstract class ComponentRef {
}
export class ComponentRef_ extends ComponentRef {
/**
* The injector provided {@link DynamicComponentLoader#loadAsRoot}.
*
* TODO(i): this api is useless and should be replaced by an injector retrieved from
* the HostElementRef, which is currently not possible.
*/
injector: Injector;
/**
* TODO(i): refactor into public/private fields
*/

View File

@ -115,7 +115,7 @@ export class ViewMetadata {
* }
* ```
*/
directives: Array<Type | Function | any[]>;
directives: Array<Type | any[]>;
pipes: Array<Type | any[]>;

View File

@ -13,12 +13,7 @@ import {Map} from 'angular2/src/core/facade/collection';
*
* <!-- TODO: this is created by Renderer#createProtoView in the new compiler -->
*/
export abstract class RenderProtoViewRef {}
export class RenderProtoViewRef_ extends RenderProtoViewRef {
constructor() { super(); }
}
export class RenderProtoViewRef {}
/**
* Represents a list of sibling Nodes that can be moved by the {@link Renderer} independently of

View File

@ -12,7 +12,7 @@ import {Map, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collec
import {RouteHandler} from './route_handler';
import {Url, RootUrl, serializeParams} from './url_parser';
import {ComponentInstruction, ComponentInstruction_} from "./instruction";
import {ComponentInstruction, ComponentInstruction_} from './instruction';
class TouchMap {
map: {[key: string]: string} = {};

View File

@ -1,6 +1,6 @@
import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async';
import {StringMapWrapper} from 'angular2/src/core/facade/collection';
import {isBlank, isPresent, Type} from 'angular2/src/core/facade/lang';
import {isBlank, isPresent} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
import {Directive, Attribute} from 'angular2/src/core/metadata';

View File

@ -57,9 +57,9 @@ import {APP_ID} from 'angular2/src/core/application_tokens';
import {Serializer} from "angular2/src/web_workers/shared/serializer";
import {Log} from './utils';
import {compilerBindings} from 'angular2/src/core/compiler/compiler';
import {DomRenderer_} from "../core/render/dom/dom_renderer";
import {DynamicComponentLoader_} from "../core/linker/dynamic_component_loader";
import {AppViewManager_} from "../core/linker/view_manager";
import {DomRenderer_} from "angular2/src/core/render/dom/dom_renderer";
import {DynamicComponentLoader_} from "angular2/src/core/linker/dynamic_component_loader";
import {AppViewManager_} from "angular2/src/core/linker/view_manager";
/**
* Returns the root injector bindings.

View File

@ -18,6 +18,7 @@ import {
Binding
} from 'angular2/core';
import {DependencyMetadata} from 'angular2/src/core/di/metadata';
import {ResolvedBinding_} from 'angular2/src/core/di/binding';
import {
InjectorInlineStrategy,
@ -577,7 +578,7 @@ export function main() {
var bindings = Injector.resolve([Engine, [BrokenEngine]]);
bindings.forEach(function(b) {
if (isBlank(b)) return; // the result is a sparse array
expect(b instanceof ResolvedBinding).toBe(true);
expect(b instanceof ResolvedBinding_).toBe(true);
});
});

View File

@ -7,7 +7,7 @@ import {
it,
expect
} from "angular2/test_lib";
import {RenderProtoViewRef, RenderProtoViewRef_} from "angular2/src/core/render/api";
import {RenderProtoViewRef} from "angular2/src/core/render/api";
import {RenderProtoViewRefStore} from "angular2/src/web_workers/shared/render_proto_view_ref_store";
import {
WebWorkerRenderProtoViewRef
@ -36,14 +36,14 @@ export function main() {
beforeEach(() => { store = new RenderProtoViewRefStore(false); });
it("should associate views with the correct references", () => {
var renderProtoViewRef = new RenderProtoViewRef_();
var renderProtoViewRef = new RenderProtoViewRef();
store.store(renderProtoViewRef, 100);
expect(store.deserialize(100)).toBe(renderProtoViewRef);
});
it("should be serializable", () => {
var renderProtoViewRef = new RenderProtoViewRef_();
var renderProtoViewRef = new RenderProtoViewRef();
store.store(renderProtoViewRef, 0);
var deserialized = store.deserialize(store.serialize(renderProtoViewRef));

View File

@ -11,7 +11,7 @@ import {
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
import {ListWrapper} from 'angular2/src/core/facade/collection';
import {getIntParameter, bindAction} from 'angular2/src/test_lib/benchmark_util';
import {ComponentRef_} from "../../../angular2/src/core/linker/dynamic_component_loader";
import {ComponentRef} from "angular2/src/core/linker/dynamic_component_loader";
var testList = null;
@ -21,7 +21,7 @@ export function main() {
bootstrap(AppComponent)
.then((ref) => {
var injector = (<ComponentRef_>ref).injector;
var injector = ref.injector;
var app: AppComponent = ref.hostComponent;
var lifeCycle = injector.get(LifeCycle);

View File

@ -26,7 +26,7 @@ import {ListWrapper} from 'angular2/src/core/facade/collection';
import {Inject} from 'angular2/src/core/di/decorators';
import {reflector} from 'angular2/src/core/reflection/reflection';
import {ComponentRef_} from "../../../angular2/src/core/linker/dynamic_component_loader";
import {ComponentRef} from "angular2/src/core/linker/dynamic_component_loader";
export const BENCHMARK_TYPE = 'LargetableComponent.benchmarkType';
export const LARGETABLE_ROWS = 'LargetableComponent.rows';
@ -125,7 +125,7 @@ export function main() {
function initNg2() {
bootstrap(AppComponent, _createBindings())
.then((ref) => {
var injector = (<ComponentRef_>ref).injector;
var injector = ref.injector;
app = ref.hostComponent;
lifecycle = injector.get(LifeCycle);
bindAction('#ng2DestroyDom', ng2DestroyDom);

View File

@ -23,7 +23,7 @@ import {
} from 'angular2/src/test_lib/benchmark_util';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
import {ComponentRef_} from "../../../angular2/src/core/linker/dynamic_component_loader";
import {ComponentRef} from "angular2/src/core/linker/dynamic_component_loader";
function createBindings(): Binding[] {
var viewCacheCapacity = getStringParameter('viewcache') == 'true' ? 10000 : 1;
@ -94,7 +94,7 @@ export function main() {
function initNg2() {
bootstrap(AppComponent, createBindings())
.then((ref) => {
var injector = (<ComponentRef_>ref).injector;
var injector = ref.injector;
lifeCycle = injector.get(LifeCycle);
app = ref.hostComponent;

View File

@ -34,7 +34,7 @@ import {
} from './constants';
import {Ng2ComponentFacade} from './ng2_facade';
import {ExportedNg1Component} from './ng1_facade';
import {NgZone_} from "../../angular2/src/core/zone/ng_zone";
import {NgZone_} from "angular2/src/core/zone/ng_zone";
var moduleCount: number = 0;