-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.svelte
179 lines (152 loc) · 4.32 KB
/
App.svelte
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<script>
import { postData } from './post-data.js';
import { onMount } from 'svelte';
import HeapSize from './HeapSize.svelte';
import HeapLive from './HeapLive.svelte';
import HeapAllocated from './HeapAllocated.svelte';
import ActiveThreads from './ActiveThreads.svelte';
import CostCentreStack from './CostCentreStack.svelte';
import ModuleBrowser from './ModuleBrowser.svelte';
let response;
let restResponse = '';
//let eventlogFilepath = '/home/csaba/haskell/grin-compiler/ghc-wpc-sample-programs/game-logic-experiment/.stack-work/dist/x86_64-linux/Cabal-3.2.0.0/build/minigame/minigame.eventlog';
let eventlogFilepath = '../data/grin.eventlog';
let eventlogOffset = 0;
let eventlogIndex = 100000;
let eventKinds = [];
let eventlog;
let useEventlog = true;
async function fetchEventData() {
let data = await postData('http://localhost:3000/eventlog',{
path: eventlogFilepath,
offset: eventlogOffset,
// idx: eventlogIndex,
'event-type': eventKinds
});
restResponse = "<h3> got eventlog json, check console </h3>";
console.log('response: ', data);
eventlog = data;
}
let diagramOptions = [
{ text: 'Heap Size'
, value: 'HeapSize'
, eventlogFilter: ['HeapSize']
},
{ text: 'Heap Live (Chart Zoo)'
, value: 'HeapLive'
, eventlogFilter: ['HeapLive', 'HeapSize']
},
{ text: 'Heap Allocated'
, value: 'HeapAllocated'
, eventlogFilter: ['HeapAllocated']
},
{ text: 'Active Threads'
, value: 'ActiveThreads'
, eventlogFilter: ['RunThread', 'StopThread']
},
{ text: 'Cost Centre Stack'
, value: 'CostCentreStack'
, eventlogFilter: ['HeapSize', 'HeapLive', 'HeapProfCostCentre', 'HeapProfSampleCostCentre', 'ProfSampleCostCentre', 'GCWork']
},
{ text: 'Module Browser'
, value: 'ModuleBrowser'
, eventlogFilter: null // not all view requires eventlog data
}
];
let diagramMode = 'CostCentreStack';
let diagramSelected;
$: if (diagramSelected) {
diagramMode = diagramSelected.value;
eventKinds = diagramSelected.eventlogFilter;
// not all view requires eventlog data
useEventlog = eventKinds !== null;
if (useEventlog) {
fetchEventData();
}
}
</script>
<style>
:global(html, body) {
font-size: 12px;
padding: 0;
}
:global(text.chart-title) {
font-size: 1.7em;
font-family: sans-serif;
}
:global(.line-path) {
fill: none;
stroke: maroon;
stroke-width: 2;
stroke-linejoin: round;
}
:global(.live-line-path) {
fill: none;
stroke: steelblue;
stroke-width: 2;
stroke-linejoin: round;
}
:global(.tick text) {
font-size: 1.2em;
font-family: sans-serif;
fill: #635F5D;
}
:global(.tick line) {
stroke: #C0C0BB;
}
.my-nav {
width: 100%;
height: auto;
display: flex;
align-items: center;
background: #5f5286;
color: white;
}
.my-nav > * {
margin: 0.5em;
}
.my-title {
padding: 0.1em 0.3em;
margin: 0;
}
.fullscreen {
height: 100vh;
display: flex;
flex-flow: column;
align-items: stretch;
background: yellow;
}
.top-container {
padding: 0.5em;
}
</style>
<div class:fullscreen="{diagramMode === 'ModuleBrowser'}" class="top-container">
<nav class="my-nav">
<h3 class="my-title">
Haskell Code Spot
</h3>
<select bind:value={diagramSelected}>
{#each diagramOptions as diagramOption}
<option value={diagramOption} selected={diagramMode === diagramOption.value}>
{diagramOption.text}
</option>
{/each}
</select>
<label for="myfile">Eventlog file:</label>
<input type="text" name="myfile" bind:value={eventlogFilepath} title={eventlogFilepath} style="flex-grow:1;">
<button on:click={fetchEventData} disabled='{!useEventlog}'>Fetch Event Data</button>
</nav>
{#if diagramMode === 'HeapSize'}
<HeapSize eventlogData={eventlog}/>
{:else if diagramMode === 'HeapLive'}
<HeapLive eventlogData={eventlog}/>
{:else if diagramMode === 'HeapAllocated'}
<HeapAllocated eventlogData={eventlog}/>
{:else if diagramMode === 'ActiveThreads'}
<ActiveThreads eventlogData={eventlog}/>
{:else if diagramMode === 'CostCentreStack'}
<CostCentreStack eventlogData={eventlog}/>
{:else if diagramMode === 'ModuleBrowser'}
<ModuleBrowser/>
{/if}
</div>