• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript benchmark_util.bindAction函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: bindAction

      .then((ref) => {
        var injector = ref.injector;
        var app: AppComponent = ref.instance;
        var appRef = injector.get(ApplicationRef);

        bindAction('#reset', function() {
          app.reset();
          appRef.tick();
        });

        // Baseline (plain components)
        bindAction('#createPlainComponents', function() {
          app.createPlainComponents();
          appRef.tick();
        });

        // Components with decorators
        bindAction('#createComponentsWithDirectives', function() {
          app.createComponentsWithDirectives();
          appRef.tick();
        });

        // Components with decorators
        bindAction('#createDynamicComponents', function() {
          app.createDynamicComponents();
          appRef.tick();
        });
      });
开发者ID:0xJoKe,项目名称:angular,代码行数:28,代码来源:index.ts


示例2: platformBrowserDynamic

  platformBrowserDynamic().bootstrapModule(AppModule).then((ref) => {
    const injector = ref.injector;
    const app: AppComponent = ref.instance;
    const appRef = injector.get(ApplicationRef);

    bindAction('#reset', function() {
      app.reset();
      appRef.tick();
    });

    // Baseline (plain components)
    bindAction('#createPlainComponents', function() {
      app.createPlainComponents();
      appRef.tick();
    });

    // Components with decorators
    bindAction('#createComponentsWithDirectives', function() {
      app.createComponentsWithDirectives();
      appRef.tick();
    });

    // Components with decorators
    bindAction('#createDynamicComponents', function() {
      app.createDynamicComponents();
      appRef.tick();
    });
  });
开发者ID:AlmogShaul,项目名称:angular,代码行数:28,代码来源:index.ts


示例3: main

export function main() {
  BrowserDomAdapter.makeCurrent();
  var count = getIntParameter('selectors');

  var fixedMatcher;
  var fixedSelectorStrings = [];
  var fixedSelectors = [];
  for (var i = 0; i < count; i++) {
    fixedSelectorStrings.push(randomSelector());
  }
  for (var i = 0; i < count; i++) {
    fixedSelectors.push(CssSelector.parse(fixedSelectorStrings[i]));
  }
  fixedMatcher = new SelectorMatcher();
  for (var i = 0; i < count; i++) {
    fixedMatcher.addSelectables(fixedSelectors[i], i);
  }

  function parse() {
    var result = [];
    for (var i = 0; i < count; i++) {
      result.push(CssSelector.parse(fixedSelectorStrings[i]));
    }
    return result;
  }

  function addSelectable() {
    var matcher = new SelectorMatcher();
    for (var i = 0; i < count; i++) {
      matcher.addSelectables(fixedSelectors[i], i);
    }
    return matcher;
  }

  function match() {
    var matchCount = 0;
    for (var i = 0; i < count; i++) {
      fixedMatcher.match(fixedSelectors[i][0], (selector, selected) => { matchCount += selected; });
    }
    return matchCount;
  }

  bindAction('#parse', parse);
  bindAction('#addSelectable', addSelectable);
  bindAction('#match', match);
}
开发者ID:0xJoKe,项目名称:angular,代码行数:46,代码来源:selector_benchmark.ts


示例4: function

      function($rootScope) {
        let count = 0;
        const maxDepth = getIntParameter('depth');

        bindAction('#destroyDom', destroyDom);
        bindAction('#createDom', createDom);

        function destroyDom() {
          $rootScope.$apply(function() { $rootScope.initData = new TreeNode('', null, null); });
        }

        function createDom() {
          const values = count++ % 2 == 0 ? ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
                                          ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];

          $rootScope.$apply(function() { $rootScope.initData = buildTree(maxDepth, values, 0); });
        }
      }
开发者ID:AlmogShaul,项目名称:angular,代码行数:18,代码来源:tree_benchmark.ts


示例5: constructor

 constructor() {
   let appSize = getIntParameter('appSize');
   this.iterationCount = getIntParameter('iterationCount');
   this.scrollIncrement = getIntParameter('scrollIncrement');
   appSize = appSize > 1 ? appSize - 1 : 0;  // draw at least one table
   this.scrollAreas = [];
   for (let i = 0; i < appSize; i++) {
     this.scrollAreas.push(i);
   }
   bindAction('#run-btn', () => { this.runBenchmark(); });
   bindAction('#reset-btn', () => {
     this._getScrollDiv().scrollTop = 0;
     const existingMarker = this._locateFinishedMarker();
     if (existingMarker != null) {
       DOM.removeChild(document.body, existingMarker);
     }
   });
 }
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:18,代码来源:app.ts


示例6: main

export function main() {
  var count = 0;
  var maxDepth = getIntParameter('depth');

  bindAction('#destroyDom', destroyDom);
  bindAction('#createDom', createDom);

  var empty = new TreeNode(0, null, null);
  var rootComponent = React.render(React.createElement(TreeComponent, {treeNode: empty}, ""),
                                   document.getElementById('rootTree'));

  function destroyDom() { rootComponent.setProps({treeNode: empty}); }

  function createDom() {
    var values = count++ % 2 == 0 ? ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
                                    ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
    rootComponent.setProps({treeNode: buildTree(maxDepth, values, 0)});
  }
}
开发者ID:awerlang,项目名称:angular,代码行数:19,代码来源:index.ts


示例7: function

      function($rootScope) {
        var count = 0;
        $rootScope.initData = null;

        bindAction('#destroyDom', destroyDom);
        bindAction('#createDom', createDom);

        function createData(): TreeNode {
          var values = count++ % 2 == 0 ? ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'] :
                                          ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '-'];
          return buildTree(MAX_DEPTH, values, 0);
        }

        function destroyDom() {
          $rootScope.$apply(function() { $rootScope.initData = null; });
        }

        function createDom() {
          $rootScope.$apply(function() { $rootScope.initData = createData(); });
        }
      }
开发者ID:awerlang,项目名称:angular,代码行数:21,代码来源:tree_benchmark.ts


示例8: function

                function($scope) {
                  bindAction('#destroyDom', destroyDom);
                  bindAction('#createDom', createDom);

                  function destroyDom() {
                    $scope.$apply(function() { $scope.benchmarkType = 'none'; });
                  }

                  function createDom() {
                    $scope.$apply(function() { $scope.benchmarkType = benchmarkType; });
                  }

                  var data = $scope.data = [];

                  function iGetter() { return this.i; }
                  function jGetter() { return this.j; }

                  for (var i = 0; i < totalRows; i++) {
                    data[i] = [];
                    for (var j = 0; j < totalColumns; j++) {
                      data[i][j] = {i: i, j: j, iFn: iGetter, jFn: jGetter};
                    }
                  }
                })
开发者ID:awerlang,项目名称:angular,代码行数:24,代码来源:largetable_benchmark.ts


示例9: main

export function main() {
  BrowserDomAdapter.makeCurrent();
  var iterations = getIntParameter('iterations');

  // This benchmark does not use bootstrap and needs to create a reflector
  setupReflector();
  var bindings = [A, B, C, D, E];
  var injector = ReflectiveInjector.resolveAndCreate(bindings);

  var D_KEY = ReflectiveKey.get(D);
  var E_KEY = ReflectiveKey.get(E);
  var childInjector = injector.resolveAndCreateChild([])
                          .resolveAndCreateChild([])
                          .resolveAndCreateChild([])
                          .resolveAndCreateChild([])
                          .resolveAndCreateChild([]);

  var variousProviders = [A, {provide: B, useClass: C}, [D, [E]], {provide: F, useValue: 6}];

  var variousProvidersResolved = ReflectiveInjector.resolve(variousProviders);

  function getByToken() {
    for (var i = 0; i < iterations; ++i) {
      injector.get(D);
      injector.get(E);
    }
  }
  function getByKey() {
    for (var i = 0; i < iterations; ++i) {
      injector.get(D_KEY);
      injector.get(E_KEY);
    }
  }

  function getChild() {
    for (var i = 0; i < iterations; ++i) {
      childInjector.get(D);
      childInjector.get(E);
    }
  }

  function instantiate() {
    for (var i = 0; i < iterations; ++i) {
      var child = injector.resolveAndCreateChild([E]);
      child.get(E);
    }
  }

  /**
   * Creates an injector with a variety of provider types.
   */
  function createVariety() {
    for (var i = 0; i < iterations; ++i) {
      ReflectiveInjector.resolveAndCreate(variousProviders);
    }
  }

  /**
   * Same as [createVariety] but resolves providers ahead of time.
   */
  function createVarietyResolved() {
    for (var i = 0; i < iterations; ++i) {
      ReflectiveInjector.fromResolvedProviders(variousProvidersResolved);
    }
  }

  bindAction('#getByToken', () => microBenchmark('injectAvg', iterations, getByToken));
  bindAction('#getByKey', () => microBenchmark('injectAvg', iterations, getByKey));
  bindAction('#getChild', () => microBenchmark('injectAvg', iterations, getChild));
  bindAction('#instantiate', () => microBenchmark('injectAvg', iterations, instantiate));
  bindAction('#createVariety', () => microBenchmark('injectAvg', iterations, createVariety));
  bindAction(
      '#createVarietyResolved',
      () => microBenchmark('injectAvg', iterations, createVarietyResolved));
}
开发者ID:JanStureNielsen,项目名称:angular,代码行数:75,代码来源:di_benchmark.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript benchmark_util.getIntParameter函数代码示例发布时间:2022-05-28
下一篇:
TypeScript testing.TestComponentBuilder类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap