mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 10:11:03 +00:00
Replaced timely dependency
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import debug from 'debug';
|
||||
import { createSelector, createStructuredSelector } from 'reselect';
|
||||
import { Map as makeMap } from 'immutable';
|
||||
import timely from 'timely';
|
||||
|
||||
import { initEdgesFromNodes } from '../utils/layouter-utils';
|
||||
import { viewportWidthSelector, viewportHeightSelector } from './canvas-viewport';
|
||||
import { activeTopologyOptionsSelector } from './topology';
|
||||
import { shownNodesSelector } from './node-filters';
|
||||
import { doLayout } from '../charts/nodes-layout';
|
||||
import timer from '../utils/timer-utils';
|
||||
|
||||
const log = debug('scope:nodes-chart');
|
||||
|
||||
@@ -49,7 +49,7 @@ const graphLayoutSelector = createSelector(
|
||||
}
|
||||
|
||||
const edges = initEdgesFromNodes(nodes);
|
||||
const timedLayouter = timely(doLayout);
|
||||
const timedLayouter = timer(doLayout);
|
||||
const graph = timedLayouter(nodes, edges, options);
|
||||
|
||||
// NOTE: We probably shouldn't log anything in a
|
||||
|
||||
18
client/app/scripts/utils/__tests__/timer-utils-test.js
Normal file
18
client/app/scripts/utils/__tests__/timer-utils-test.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import expect from 'expect';
|
||||
import timer from '../timer-utils';
|
||||
|
||||
describe('timer', () => {
|
||||
it('records how long a function takes to execute', () => {
|
||||
const add100k = (number) => {
|
||||
for (let i = 0; i < 100000; i += 1) {
|
||||
number += 1;
|
||||
}
|
||||
return number;
|
||||
};
|
||||
|
||||
const timedFn = timer(add100k);
|
||||
const result = timedFn(70);
|
||||
expect(result).toEqual(100070);
|
||||
expect(timedFn.time).toBeA('number');
|
||||
});
|
||||
});
|
||||
11
client/app/scripts/utils/timer-utils.js
Normal file
11
client/app/scripts/utils/timer-utils.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// Replacement for timely dependency
|
||||
|
||||
export default function timer(fn) {
|
||||
const timedFn = (...args) => {
|
||||
const start = new Date();
|
||||
const result = fn.apply(fn, args);
|
||||
timedFn.time = new Date() - start;
|
||||
return result;
|
||||
};
|
||||
return timedFn;
|
||||
}
|
||||
@@ -40,7 +40,6 @@
|
||||
"reqwest": "2.0.5",
|
||||
"reselect": "2.5.4",
|
||||
"reselect-map": "1.0.0",
|
||||
"timely": "0.1.0",
|
||||
"whatwg-fetch": "2.0.1",
|
||||
"react-addons-perf": "15.4.2",
|
||||
"xterm": "2.2.3"
|
||||
|
||||
Reference in New Issue
Block a user