-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cache for downloading graphs on compare page
- Loading branch information
Showing
2 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
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,23 @@ | ||
import {GraphData, GraphsSelector} from "./data"; | ||
import {loadGraphs} from "./api"; | ||
|
||
export class GraphResolver { | ||
private cache: Dict<GraphData> = {}; | ||
|
||
public async loadGraph(selector: GraphsSelector): Promise<GraphData> { | ||
const key = `${selector.benchmark};${selector.profile};${selector.scenario};${selector.start};${selector.end};${selector.stat};${selector.kind}`; | ||
if (!this.cache.hasOwnProperty(key)) { | ||
this.cache[key] = await loadGraphs(selector); | ||
} | ||
|
||
return this.cache[key]; | ||
} | ||
} | ||
|
||
/** | ||
* This is essentially a global variable, but it makes the code simpler and | ||
* since we currently don't have any unit tests, we don't really need to avoid | ||
* global variables that much. If needed, it could be provided to Vue components | ||
* from a parent via props or context. | ||
*/ | ||
export const GRAPH_RESOLVER = new GraphResolver(); |
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