forked from EqualGames/game-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch_and_close.js
57 lines (38 loc) · 1.43 KB
/
launch_and_close.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const {performance, PerformanceObserver} = require('perf_hooks');
const perfObserver = new PerformanceObserver((items) => {
console.log('\nPerformance status:')
items.getEntries().forEach((entry) => console.log(`- ${entry.name} ${entry.duration}ms`))
console.log();
});
perfObserver.observe({entryTypes: ["measure"], buffered: true})
const game_scanner = require("../lib");
async function main() {
performance.mark('start');
const games = game_scanner.steam.games();
performance.mark('end');
console.log(`${games.length} Steam game(s)`);
performance.measure("games", "start", "end");
const game = games.find(game => game.state.installed);
performance.mark('start');
game_scanner.manager.launch_game(game);
performance.mark('end');
console.log(`Launching: ${game.name}`);
performance.measure("launch_game", "start", "end");
await delay();
performance.mark('start');
let processes = game_scanner.manager.get_processes(game);
performance.mark('end');
console.log('Processes: ', processes);
performance.measure("game_processes", "start", "end");
await delay();
performance.mark('start');
game_scanner.manager.close_game(game);
performance.mark('end');
performance.measure("close_game", "start", "end");
}
async function delay(ms = 15000) {
return new Promise((resolve) => {
setTimeout(() => resolve(), ms)
})
}
main().catch(console.log)