Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 565ca6a

Browse files
committed
chore(benchmarks): add basic animation benchmark
1 parent 54a7caf commit 565ca6a

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

benchmarks/animation-bp/app.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use strict';
2+
3+
angular
4+
.module('animationBenchmark', ['ngAnimate'], config)
5+
.controller('BenchmarkController', BenchmarkController);
6+
7+
// Functions - Definitions
8+
function config($compileProvider) {
9+
$compileProvider
10+
.commentDirectivesEnabled(false)
11+
.cssClassDirectivesEnabled(false)
12+
.debugInfoEnabled(false);
13+
}
14+
15+
function BenchmarkController($scope) {
16+
var self = this;
17+
var itemCount = 1000;
18+
var items = (new Array(itemCount + 1)).join('.').split('');
19+
20+
benchmarkSteps.push({
21+
name: 'create',
22+
fn: function() {
23+
$scope.$apply(function() {
24+
self.items = items;
25+
});
26+
}
27+
});
28+
29+
benchmarkSteps.push({
30+
name: '$digest',
31+
fn: function() {
32+
$scope.$root.$digest();
33+
}
34+
});
35+
36+
benchmarkSteps.push({
37+
name: 'destroy',
38+
fn: function() {
39+
$scope.$apply(function() {
40+
self.items = [];
41+
});
42+
}
43+
});
44+
}

benchmarks/animation-bp/bp.conf.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-env node */
2+
3+
'use strict';
4+
5+
module.exports = function(config) {
6+
config.set({
7+
scripts: [
8+
{
9+
id: 'jquery',
10+
src: 'jquery-noop.js'
11+
}, {
12+
id: 'angular',
13+
src: '/build/angular.js'
14+
}, {
15+
id: 'angular-animate',
16+
src: '/build/angular-animate.js'
17+
}, {
18+
src: 'app.js'
19+
}
20+
]
21+
});
22+
};
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Override me with ?jquery=/bower_components/jquery/dist/jquery.js

benchmarks/animation-bp/main.html

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<style>
2+
[ng-cloak] { display: none !important; }
3+
.animation-container .ng-enter,
4+
.animation-container .ng-leave {
5+
transition: all 0.1s;
6+
}
7+
8+
.animation-container .ng-enter,
9+
.animation-container .ng-leave.ng-leave-active {
10+
opacity: 0;
11+
}
12+
13+
.animation-container .ng-enter.ng-enter-active,
14+
.animation-container .ng-leave {
15+
opacity: 1;
16+
}
17+
</style>
18+
<div ng-app="animationBenchmark" ng-cloak ng-controller="BenchmarkController as bm">
19+
<div class="container-fluid">
20+
<h2>Large collection of elements animated in and out with ngAnimate</h2>
21+
22+
<div class="animation-container">
23+
<div ng-repeat="i in bm.items track by $index">
24+
Just a plain ol' element
25+
</div>
26+
</div>
27+
</div>
28+
</div>

0 commit comments

Comments
 (0)