Skip to content

Commit e7ffe04

Browse files
authored
Merge pull request #32 from tiennou/master
Consolidate profiler changes
2 parents 4014ef5 + 841487a commit e7ffe04

11 files changed

+4157
-61
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = false
12+
insert_final_newline = false
13+
14+
[*.js]
15+
trim_trailing_whitespace = true
16+
insert_final_newline = true

.eslintrc

+41-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,56 @@
11
{
22
"extends": "airbnb",
33
"globals": {
4-
"Game": true,
4+
"ConstructionSite": true,
55
"Creep": true,
6+
"Deposit": true,
7+
"Flag": true,
8+
"Game": true,
9+
"InterShardMemory": true,
10+
"Memory": true,
11+
"Mineral": true,
12+
"Nuke": true,
13+
"OwnedStructure": true,
14+
"PathFinder": true,
15+
"PowerCreep": true,
16+
"RawMemory": true,
17+
"Resource": true,
618
"Room": true,
19+
"RoomObject": true,
720
"RoomPosition": true,
21+
"RoomVisual": true,
22+
"Ruin": true,
823
"Source": true,
9-
"Spawn": true,
24+
"Store": true,
1025
"Structure": true,
11-
"Flag": true,
12-
"Memory": true,
26+
"StructureContainer": true,
27+
"StructureController": true,
28+
"StructureExtension": true,
29+
"StructureExtractor": true,
30+
"StructureFactory": true,
31+
"StructureInvaderCore": true,
32+
"StructureKeeperLair": true,
33+
"StructureLab": true,
34+
"StructureLink": true,
35+
"StructureNuker": true,
36+
"StructureObserver": true,
37+
"StructurePortal": true,
38+
"StructurePowerBank": true,
39+
"StructurePowerSpawn": true,
40+
"StructureRampart": true,
41+
"StructureRoad": true,
42+
"StructureSpawn": true,
43+
"StructureStorage": true,
44+
"StructureTerminal": true,
45+
"StructureTower": true,
46+
"StructureWall": true,
47+
"Tombstone": true
1348
},
14-
rules: {
49+
"rules": {
1550
"no-console": 0,
1651
"arrow-body-style": 0,
1752
"prefer-rest-params": 0,
1853
"no-use-before-define": 0,
19-
"strict": 0,
54+
"strict": 0
2055
}
2156
}

.github/workflows/check.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Node.js CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Use Node.js
13+
uses: actions/setup-node@v3
14+
with:
15+
node-version: 10
16+
- run: npm install
17+
- run: npm test
18+
- name: Coveralls GitHub Action
19+
uses: coverallsapp/[email protected]
20+
with:
21+
github-token: ${{ secrets.GITHUB_TOKEN }}

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 10.24.1

.travis.yml

-6
This file was deleted.

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ Game.profiler.profile(ticks, [functionFilter]);
3737
Game.profiler.stream(ticks, [functionFilter]);
3838
Game.profiler.email(ticks, [functionFilter]);
3939
Game.profiler.background([functionFilter]);
40+
Game.profiler.callgrind(ticks, [functionFilter]);
4041

4142
// Output current profile data.
4243
Game.profiler.output([lineCount]);
44+
Game.profiler.downloadCallgrind();
4345

4446
// Reset the profiler, disabling any profiling in the process.
4547
Game.profiler.reset();
@@ -57,7 +59,11 @@ Game.profiler.restart();
5759

5860
`background` - This will run indefinitely, and will only output data when the `output` console command is run. Very useful for long running profiles with lots of function calls.
5961

60-
`output` - Print a report based on the current tick. The profiler will continue to operate normally. This is currently the only way to get data from the `background` profile.
62+
`callgrind` - Will run for the given number of ticks, and will download a file in Callgrind format which can be viewed in KCachegrind program.
63+
64+
`output` - Print a report based on the current tick. The profiler will continue to operate normally.
65+
66+
`downloadCallgrind` - Download the callgrind report at the current tick. The profiler will continue to operate normally.
6167

6268
`reset` - Stops the profiler and resets its memory. This is currently the only way to stop a `background` profile.
6369

@@ -123,6 +129,12 @@ Avg: 13.54 Total: 2707.90 Ticks: 200 Est. Bucket (20 limit): 1774
123129

124130
**Note:** Each function recorded here was part of a call stack with `Spawn.work` at the root.
125131

132+
## Example callgrind visualisation
133+
134+
![KCachegrind screenshot](callgrind.jpg)
135+
136+
**Note:** In callgrind format time will be saved in nanoseconds. `1 Screeps CPU unit = 1 ms = 1'000'000 ns`.
137+
126138
## Registering additional code
127139

128140
The profiler automatically registers many of the built in functions in Screeps, but not every player extends the provided prototypes. The profiler supports arbitrary registration of objects and functions as well, but takes a bit more work to setup.

0 commit comments

Comments
 (0)