当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript kernel.Profiler类代码示例

本文整理汇总了TypeScript中@aurelia/kernel.Profiler的典型用法代码示例。如果您正苦于以下问题:TypeScript Profiler类的具体用法?TypeScript Profiler怎么用?TypeScript Profiler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Profiler类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: writeProfilerReport

export function writeProfilerReport(testName: string): void {
  let msg = '\n';
  Profiler.report(function (name, duration, topLevel, total) {
    msg += `[Profiler:${testName}] ${padRight(name, 25)}: ${padLeft(Math.round(duration * 10) / 10, 7)}ms; ${padLeft(topLevel, 7)} measures; ${padLeft(total, 7)} calls; ~${Math.round(duration / total * 100) / 100}ms/call\n`;
  });
  console.log(msg);
}
开发者ID:aurelia,项目名称:aurelia,代码行数:7,代码来源:util.ts

示例2:

import { Profiler, Tracer, Writable } from '@aurelia/kernel';
import { Hooks, LifecycleFlags, State } from '../flags';
import { IComponent, ILifecycleHooks, IMountableComponent, IRenderable, IView } from '../lifecycle';
import { ICustomElement } from '../resources/custom-element';

interface IAttachable extends IRenderable, ILifecycleHooks, IComponent {
  constructor: {
    description?: { name: string };
    name: string;
  };
}

const slice = Array.prototype.slice;

const { enter, leave } = Profiler.createTimer('AttachLifecycle');

/** @internal */
// tslint:disable-next-line:no-ignored-initial-value
export function $attachAttribute(this: Writable<IAttachable>, flags: LifecycleFlags): void {
  if (Profiler.enabled) { enter(); }
  if (Tracer.enabled) { Tracer.enter(this.constructor.description && this.constructor.description.name || this.constructor.name, '$attach', slice.call(arguments)); }
  if (this.$state & State.isAttached) {
    if (Profiler.enabled) { leave(); }
    if (Tracer.enabled) { Tracer.leave(); }
    return;
  }
  const lifecycle = this.$lifecycle;
  lifecycle.beginAttach();
  // add isAttaching flag
  this.$state |= State.isAttaching;
  flags |= LifecycleFlags.fromAttach;
开发者ID:aurelia,项目名称:aurelia,代码行数:31,代码来源:lifecycle-attach.ts

示例3: constructor

import { DI, IContainer, IRegistry, PLATFORM, Profiler, Registration, Reporter } from '@aurelia/kernel';
import { IDOM, INode } from './dom';
import { BindingStrategy, LifecycleFlags } from './flags';
import { ProxyObserver } from './observation/proxy-observer';
import { ExposedContext } from './rendering-engine';
import { CustomElementResource, ICustomElement, ICustomElementType } from './resources/custom-element';

const { enter: enterStart, leave: leaveStart } = Profiler.createTimer('Aurelia.start');
const { enter: enterStop, leave: leaveStop } = Profiler.createTimer('Aurelia.stop');

export interface ISinglePageApp<THost extends INode = INode> {
  strategy?: BindingStrategy;
  dom?: IDOM;
  host: THost;
  component: unknown;
}

export class Aurelia {
  private readonly container: IContainer;
  private readonly components: ICustomElement[];
  private readonly startTasks: (() => void)[];
  private readonly stopTasks: (() => void)[];
  private isStarted: boolean;
  private _root: ICustomElement | null;

  constructor(container: IContainer = DI.createContainer()) {
    this.container = container;
    this.components = [];
    this.startTasks = [];
    this.stopTasks = [];
    this.isStarted = false;
开发者ID:aurelia,项目名称:aurelia,代码行数:31,代码来源:aurelia.ts

示例4:

  IsLeftHandSide,
  IsPrimary,
  IsUnary,
  IsValueConverter,
  ObjectBindingPattern,
  ObjectLiteral,
  PrimitiveLiteral,
  TaggedTemplate,
  Template,
  Unary,
  UnaryOperator,
  ValueConverter
} from '@aurelia/runtime';
import { Access, Char, Precedence, Token, unescapeCode } from './common';

const { enter, leave } = Profiler.createTimer('ExpressionParser');

const $false = PrimitiveLiteral.$false;
const $true = PrimitiveLiteral.$true;
const $null = PrimitiveLiteral.$null;
const $undefined = PrimitiveLiteral.$undefined;
const $this = AccessThis.$this;
const $parent = AccessThis.$parent;

/** @internal */
export class ParserState {
  public index: number;
  public startIndex: number;
  public input: string;
  public lastIndex: number;
  public length: number;
开发者ID:aurelia,项目名称:aurelia,代码行数:31,代码来源:expression-parser.ts

示例5: register

import {
  DefaultBindingLanguage as JitDefaultBindingLanguage,
  DefaultBindingSyntax as JitDefaultBindingSyntax,
  DefaultComponents as JitDefaultComponents
} from '@aurelia/jit';
import {
  DefaultBindingLanguage as JitHtmlDefaultBindingLanguage,
  DefaultComponents as JitHtmlDefaultComponents
} from '@aurelia/jit-html';
import { DI, IContainer, Profiler } from '@aurelia/kernel';
import { BasicConfiguration as RuntimeHtmlBrowserBasicConfiguration } from '@aurelia/runtime-html-browser';

const { enter, leave } = Profiler.createTimer('BasicConfiguration');

/**
 * A DI configuration object containing html-specific, browser-specific registrations:
 * - `BasicConfiguration` from `@aurelia/runtime-html-browser`
 * - `DefaultComponents` from `@aurelia/jit`
 * - `DefaultBindingSyntax` from `@aurelia/jit`
 * - `DefaultBindingLanguage` from `@aurelia/jit`
 * - `DefaultComponents` from `@aurelia/jit-html`
 * - `DefaultBindingLanguage` from `@aurelia/jit-html`
 */
export const BasicConfiguration = {
  /**
   * Apply this configuration to the provided container.
   */
  register(container: IContainer): IContainer {
    if (Profiler.enabled) { enter(); }
    RuntimeHtmlBrowserBasicConfiguration
      .register(container)
开发者ID:aurelia,项目名称:aurelia,代码行数:31,代码来源:index.ts

示例6:

import { Profiler, Tracer, Writable } from '@aurelia/kernel';
import { Hooks, LifecycleFlags, State } from '../flags';
import { IComponent, ILifecycleHooks, IRenderable } from '../lifecycle';
import { IPatchable, IScope } from '../observation';
import { patchProperties } from '../observation/patch-properties';

const slice = Array.prototype.slice;

const { enter, leave } = Profiler.createTimer('BindLifecycle');

interface IBindable extends IRenderable, ILifecycleHooks, IComponent {
  constructor: {
    description?: { name: string };
    name: string;
  };
}

/** @internal */
export function $bindAttribute(this: Writable<IBindable>, flags: LifecycleFlags, scope: IScope): void {
  if (Profiler.enabled) { enter(); }
  if (Tracer.enabled) { Tracer.enter(this.constructor.description && this.constructor.description.name || this.constructor.name, '$bind', slice.call(arguments)); }
  flags |= LifecycleFlags.fromBind;

  if (this.$state & State.isBound) {
    if (this.$scope === scope) {
      if (Profiler.enabled) { leave(); }
      if (Tracer.enabled) { Tracer.leave(); }
      return;
    }

    this.$unbind(flags);
开发者ID:aurelia,项目名称:aurelia,代码行数:31,代码来源:lifecycle-bind.ts

示例7:

  SymbolFlags,
  TemplateControllerSymbol,
  TextSymbol
} from '@aurelia/jit';
import { PLATFORM, Profiler, Tracer } from '@aurelia/kernel';
import {
  BindingMode,
  BindingType,
  IDOM,
  IExpressionParser
} from '@aurelia/runtime';
import { NodeType } from '@aurelia/runtime-html';

const slice = Array.prototype.slice;

const { enter, leave } = Profiler.createTimer('TemplateBinder');

const invalidSurrogateAttribute = {
  'id': true,
  'part': true,
  'replace-part': true
};

const attributesToIgnore = {
  'as-element': true,
  'part': true,
  'replace-part': true
};

/**
 * TemplateBinder. Todo: describe goal of this class
开发者ID:aurelia,项目名称:aurelia,代码行数:31,代码来源:template-binder.ts

示例8: getElementTemplate

import { IServiceLocator, PLATFORM, Profiler, Tracer, Writable } from '@aurelia/kernel';
import { IElementHydrationOptions, TemplateDefinition } from '../definitions';
import { IDOM, INode } from '../dom';
import { Hooks, LifecycleFlags } from '../flags';
import { Scope } from '../observation/binding-context';
import { ProxyObserver } from '../observation/proxy-observer';
import { IRenderingEngine, ITemplate } from '../rendering-engine';
import { ICustomAttribute, ICustomAttributeType } from '../resources/custom-attribute';
import { ICustomElement, ICustomElementType, IProjectorLocator } from '../resources/custom-element';

const slice = Array.prototype.slice;

const { enter, leave } = Profiler.createTimer('RenderLifecycle');

export interface IElementTemplateProvider {
  getElementTemplate(renderingEngine: IRenderingEngine, customElementType: ICustomElementType | null, parentContext: IServiceLocator): ITemplate;
}

export interface ILifecycleRender {
  /**
   * Only applies to `@customElement`. This hook is not invoked for `@customAttribute`s
   *
   * Called during `$hydrate`, after `this.$scope` and `this.$projector` are set.
   *
   * If this hook is implemented, it will be used instead of `renderingEngine.getElementTemplate`.
   * This allows you to completely override the default rendering behavior.
   *
   * It is the responsibility of the implementer to:
   * - Populate `this.$bindables` with any Bindings, child Views, custom elements and custom attributes
   * - Populate `this.$attachables` with any child Views, custom elements and custom attributes
   * - Populate `this.$nodes` with the nodes that need to be appended to the host
开发者ID:aurelia,项目名称:aurelia,代码行数:31,代码来源:lifecycle-render.ts


注:本文中的@aurelia/kernel.Profiler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。