-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(ReplaySubject): slightly improved performance (#2677)
* perf(ReplaySubject): slightly improved performance * perf(ReplaySubject): little performance adjustments * refactor(ReplaySubject): switch back to using splice() instead of shift() * refactor(ReplaySubject): wrap splice() with an "if" condition for performance reasons
- Loading branch information
Showing
5 changed files
with
108 additions
and
13 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
perf/micro/current-thread-scheduler/subject/replaysubject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var oldRangeWithCurrentThreadScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.currentThread); | ||
var newRangeWithCurrentThreadScheduler = RxNew.Observable.range(0, 25, RxNew.Scheduler.queue); | ||
|
||
return suite | ||
.add('old ReplaySubject with immediate scheduler', function () { | ||
var subject = new RxOld.ReplaySubject(5, Number.POSITIVE_INFINITY, RxOld.Scheduler.currentThread); | ||
oldRangeWithCurrentThreadScheduler.subscribe(subject); | ||
}) | ||
.add('new ReplaySubject with immediate scheduler', function () { | ||
var subject = new RxNew.ReplaySubject(5, Number.POSITIVE_INFINITY, RxNew.Scheduler.queue); | ||
newRangeWithCurrentThreadScheduler.subscribe(subject); | ||
}); | ||
}; |
17 changes: 17 additions & 0 deletions
17
perf/micro/current-thread-scheduler/subject/replaysubject_windowtime.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var oldRangeWithCurrentThreadScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.currentThread); | ||
var newRangeWithCurrentThreadScheduler = RxNew.Observable.range(0, 25, RxNew.Scheduler.queue); | ||
|
||
return suite | ||
.add('old ReplaySubject with immediate scheduler', function () { | ||
var subject = new RxOld.ReplaySubject(5, 50, RxOld.Scheduler.currentThread); | ||
oldRangeWithCurrentThreadScheduler.subscribe(subject); | ||
}) | ||
.add('new ReplaySubject with immediate scheduler', function () { | ||
var subject = new RxNew.ReplaySubject(5, 50, RxNew.Scheduler.queue); | ||
newRangeWithCurrentThreadScheduler.subscribe(subject); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var oldRangeWithImmediateScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.immediate); | ||
var newRangeWithImmediateScheduler = RxNew.Observable.range(0, 25); | ||
|
||
return suite | ||
.add('old ReplaySubject with immediate scheduler', function () { | ||
var subject = new RxOld.ReplaySubject(5, Number.POSITIVE_INFINITY, RxOld.Scheduler.immediate); | ||
oldRangeWithImmediateScheduler.subscribe(subject); | ||
}) | ||
.add('new ReplaySubject with immediate scheduler', function () { | ||
var subject = new RxNew.ReplaySubject(5, Number.POSITIVE_INFINITY); | ||
newRangeWithImmediateScheduler.subscribe(subject); | ||
}); | ||
}; |
17 changes: 17 additions & 0 deletions
17
perf/micro/immediate-scheduler/subject/replaysubject_windowtime.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var oldRangeWithImmediateScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.immediate); | ||
var newRangeWithImmediateScheduler = RxNew.Observable.range(0, 25); | ||
|
||
return suite | ||
.add('old ReplaySubject with immediate scheduler', function () { | ||
var subject = new RxOld.ReplaySubject(5, 50, RxOld.Scheduler.immediate); | ||
oldRangeWithImmediateScheduler.subscribe(subject); | ||
}) | ||
.add('new ReplaySubject with immediate scheduler', function () { | ||
var subject = new RxNew.ReplaySubject(5, 50); | ||
newRangeWithImmediateScheduler.subscribe(subject); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters