nope/test/testObservable.ts

27 lines
571 B
TypeScript
Raw Normal View History

2021-10-18 06:02:29 +00:00
import { NopeObservable } from "../lib/observables/nopeObservable";
2020-08-25 22:11:26 +00:00
import { generateBenchmarkFunction } from "../modules/funcs/generateBenchmarkFunction";
let max = 10000000;
2021-10-18 06:02:29 +00:00
const benchmark = generateBenchmarkFunction(max, "");
const observable = new NopeObservable<number>();
2020-08-25 22:11:26 +00:00
max = max * 10;
2021-10-18 06:02:29 +00:00
let i = 0;
2020-08-25 22:11:26 +00:00
2021-10-18 06:02:29 +00:00
const subscription = observable.subscribe({
2020-08-25 22:11:26 +00:00
next: benchmark
2021-10-18 06:02:29 +00:00
});
2020-08-25 22:11:26 +00:00
while (i < max) {
2020-08-30 10:00:31 +00:00
observable.setContent(i);
2020-08-25 22:11:26 +00:00
i++;
}
subscription.unsubscribe();
i = 0;
observable.enhancedSubscription(benchmark);
while (i < max) {
observable.observable.next(i);
i++;
}