diff options
| author | Igor Minar | 2010-12-22 13:19:26 -0800 | 
|---|---|---|
| committer | Igor Minar | 2010-12-22 14:16:36 -0800 | 
| commit | e7a0fb250f6cc69c93daffe0d043d073fd488c03 (patch) | |
| tree | a799e9264a131a9124de7983b5655b9e97df44ba /perf | |
| parent | e3ddc2bcc48ba6160455c4ffe35df87715c05693 (diff) | |
| download | angular.js-e7a0fb250f6cc69c93daffe0d043d073fd488c03.tar.bz2 | |
fromJson delegation to native JSON parser if available
- native parser delegation
- $xhr change to use native parser
Diffstat (limited to 'perf')
| -rw-r--r-- | perf/jsonPerfSpec.js | 51 | 
1 files changed, 12 insertions, 39 deletions
| diff --git a/perf/jsonPerfSpec.js b/perf/jsonPerfSpec.js index c232aed8..01a489e2 100644 --- a/perf/jsonPerfSpec.js +++ b/perf/jsonPerfSpec.js @@ -1,55 +1,28 @@  describe('json', function() { -  xit('should parse json in a reasonable time', function() { -    var totalSubstr = 0, -        totalGetMatch = 0, -        totalConsume = 0, -        totalTime = 0, -        runTimes = []; -     -    for (var i=0; i<10; i++) { -      window.substrTime = 0; -      window.getMatchTime = 0; -      window.consumeTime = 0; -      var start = Date.now(); -      expect(angular.fromJson(largeJsonString)).toBeTruthy(); -      var time = Date.now() - start; -//      dump('parse time', time, 'consume', window.consumeTime, -//                               'substr', window.substrTime, -//                               'getMatch', window.getMatchTime); -      totalTime += time; -      totalSubstr += window.substrTime; -      totalGetMatch += window.getMatchTime; -      totalConsume += window.consumeTime; -      runTimes.push(time); -    } - -    totalGetMatch = totalGetMatch - totalSubstr; - -    dump("totals", totalTime, -          "| consume", totalConsume, '' + Math.round(totalConsume/(totalTime/100)) + '%', -          "| substr", totalSubstr, '' + Math.round(totalSubstr/(totalTime/100)) + '%', -          "| getMatch", totalGetMatch, '' + Math.round(totalGetMatch/(totalTime/100)) + '%'); -    dump("run times", runTimes); -    delete window.consumeTime; -    delete window.substrTime; -    delete window.getMatchTime; -  }); -    it('angular parser', function() {      var duration = time(function() {        expect(angular.fromJson(largeJsonString)).toBeTruthy();      }, 1); -    expect(duration).toBeLessThan(4000); +    dump(duration/1 + ' ms per iteration'); +  }); + + +  it('angular delegating to native parser', function() { +    var duration = time(function() { +      expect(angular.fromJson(largeJsonString, true)).toBeTruthy(); +    }, 100); + +    dump(duration/100 + ' ms per iteration');    });    it('native json', function() {      var duration = time(function() {        expect(JSON.parse(largeJsonString)).toBeTruthy(); -    }, 1); +    }, 100); -    expect(duration).toBeLessThan(200); +    dump(duration/100 + ' ms per iteration');    });  }); | 
