JSON.parse versus angular.fromJson (v3)

Revision 3 of this benchmark created on


Description

Compare the performance between JSON.parse method and angular.fromJson method. Both are used to deserialize a JSON string.

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"></script>

<script>
angular
    .module("testApp",[])
    .controller("testController", function($scope) {
        window.ngScope = $scope;
    });
</script>

<div ng-app="testApp">    
</div>

Setup

var string = '{"text": "100", "modifiers": "notification, success", "some": "else", "test": "value", "text": "100", "modifiers": "notification, success", "some": "else", "test": "value", "text": "100", "modifiers": "notification, success", "some": "else", "test": "value", "text": "100", "modifiers": "notification, success", "some": "else", "test": "value", "text": "100", "modifiers": "notification, success", "some": "else", "test": "value", "text": "100", "modifiers": "notification, success", "some": "else", "test": "value", "text": "100", "modifiers": "notification, success", "some": "else", "test": "value"}';

Test runner

Ready to run.

Testing in
TestOps/sec
JSON.parse
var result = JSON.parse(string);
ready
angular.fromJson
var result = angular.fromJson(string);
ready
$scope.$eval
var result = window.ngScope.$eval(string)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.