當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript benchmark_util.bindAction函數代碼示例

本文整理匯總了TypeScript中angular2/src/test_lib/benchmark_util.bindAction函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript bindAction函數的具體用法?TypeScript bindAction怎麽用?TypeScript bindAction使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了bindAction函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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:CADBOT,項目名稱:angular,代碼行數:29,代碼來源:largetable_benchmark.ts

示例2: bindAction

      .then((ref) => {
        var injector = ref.injector;
        var app: AppComponent = injector.get(AppComponent);
        var lifeCycle = injector.get(LifeCycle);

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

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

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

        // Components with decorators
        bindAction('#createDynamicComponents', function() {
          app.createDynamicComponents();
          lifeCycle.tick();
        });
      });
開發者ID:B-Thapa,項目名稱:angular,代碼行數:28,代碼來源:index.ts

示例3: main

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

  reflector.reflectionCapabilities = new ReflectionCapabilities();
  var appInjector = Injector.resolveAndCreate([]);

  var bindings = [
    DirectiveBinding.createFromType(A, null),
    DirectiveBinding.createFromType(B, null),
    DirectiveBinding.createFromType(C, null)
  ];
  var proto = ProtoElementInjector.create(null, 0, bindings, false, 0);
  var elementInjector = proto.instantiate(null);

  function instantiate() {
    for (var i = 0; i < iterations; ++i) {
      var ei = proto.instantiate(null);
      ei.hydrate(appInjector, null, null);
    }
  }

  function hydrate() {
    for (var i = 0; i < iterations; ++i) {
      elementInjector.dehydrate();
      elementInjector.hydrate(appInjector, null, null);
    }
  }

  bindAction('#instantiate', () => microBenchmark('instantiateAvg', iterations, instantiate));
  bindAction('#hydrate', () => microBenchmark('instantiateAvg', iterations, hydrate));
}
開發者ID:B-Thapa,項目名稱:angular,代碼行數:32,代碼來源:element_injector_benchmark.ts

示例4: main

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

  var fixedMatcher;
  var fixedSelectorStrings = [];
  var fixedSelectors = [];
  for (var i = 0; i < count; i++) {
    ListWrapper.push(fixedSelectorStrings, randomSelector());
  }
  for (var i = 0; i < count; i++) {
    ListWrapper.push(fixedSelectors, 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++) {
      ListWrapper.push(result, 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:B-Thapa,項目名稱:angular,代碼行數:46,代碼來源:selector_benchmark.ts

示例5: function

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

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

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

        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', '-'];

          $rootScope.$apply(function() { $rootScope.initData = buildTree(maxDepth, values, 0); });
        }
      }
開發者ID:Salim-K,項目名稱:angular,代碼行數:18,代碼來源:tree_benchmark.ts

示例6: constructor

 constructor() {
   var 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 (var i = 0; i < appSize; i++) {
     ListWrapper.push(this.scrollAreas, i);
   }
   bindAction('#run-btn', () => { this.runBenchmark(); });
   bindAction('#reset-btn', () => {
     this._getScrollDiv().scrollTop = 0;
     var existingMarker = this._locateFinishedMarker();
     if (isPresent(existingMarker)) {
       DOM.removeChild(document.body, existingMarker);
     }
   });
 }
開發者ID:B-Thapa,項目名稱:angular,代碼行數:18,代碼來源:app.ts

示例7: 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:AsherBarak,項目名稱:angular,代碼行數:19,代碼來源:index.ts

示例8: function

      function($compile) {
        var count = getIntParameter('elements');
        var templateNoBindings = loadTemplate('templateNoBindings', count);
        var templateWithBindings = loadTemplate('templateWithBindings', count);

        bindAction('#compileWithBindings', compileWithBindings);
        bindAction('#compileNoBindings', compileNoBindings);

        function compileNoBindings() {
          // Need to clone every time as the compiler might modify the template!
          var cloned = templateNoBindings.cloneNode(true);
          $compile(cloned);
        }

        function compileWithBindings() {
          // Need to clone every time as the compiler might modify the template!
          var cloned = templateWithBindings.cloneNode(true);
          $compile(cloned);
        }
      }
開發者ID:Salim-K,項目名稱:angular,代碼行數:20,代碼來源:compiler_benchmark.ts

示例9: 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:goderbauer,項目名稱:angular,代碼行數:21,代碼來源:tree_benchmark.ts

示例10: 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 = Injector.resolveAndCreate(bindings);

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

  var variousBindings = [A, bind(B).toClass(C), [D, [E]], bind(F).toValue(6)];

  var variousBindingsResolved = Injector.resolve(variousBindings);

  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 binding types.
   */
  function createVariety() {
    for (var i = 0; i < iterations; ++i) {
      Injector.resolveAndCreate(variousBindings);
    }
  }

  /**
   * Same as [createVariety] but resolves bindings ahead of time.
   */
  function createVarietyResolved() {
    for (var i = 0; i < iterations; ++i) {
      Injector.fromResolvedBindings(variousBindingsResolved);
    }
  }

  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:goderbauer,項目名稱:angular,代碼行數:74,代碼來源:di_benchmark.ts


注:本文中的angular2/src/test_lib/benchmark_util.bindAction函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。