Add io version
Showing 1 of 1 files from the diff.
src/core.jl
changed.
@@ -189,90 +189,96 @@
Loading
189 | 189 | return CPUProfile(nodes, start_time, start_time + sum(timeDeltas), samples, timeDeltas) |
|
190 | 190 | end |
|
191 | 191 | ||
192 | - | function save_cpuprofile(filename, data::Union{Nothing, Vector{UInt}} = nothing, |
|
192 | + | function save_cpuprofile(io::IO, data::Union{Nothing, Vector{UInt}} = nothing, |
|
193 | 193 | period::Union{Nothing, UInt64} = nothing; kwargs...) |
|
194 | 194 | ||
195 | 195 | profile = CPUProfile(data, period; kwargs...) |
|
196 | - | open(filename, "w") do io |
|
196 | + | write(io, '{') |
|
197 | + | JSON.print(io, "nodes") |
|
198 | + | write(io, ':') |
|
199 | + | write(io, '[') |
|
200 | + | for (i, node) in enumerate(profile.nodes) |
|
197 | 201 | write(io, '{') |
|
198 | - | JSON.print(io, "nodes") |
|
202 | + | JSON.print(io, "id") |
|
199 | 203 | write(io, ':') |
|
200 | - | write(io, '[') |
|
201 | - | for (i, node) in enumerate(profile.nodes) |
|
202 | - | write(io, '{') |
|
203 | - | JSON.print(io, "id") |
|
204 | + | JSON.print(io, node.id) |
|
205 | + | write(io, ',') |
|
206 | + | JSON.print(io, "callFrame") |
|
207 | + | write(io, ':') |
|
208 | + | write(io, '{') |
|
209 | + | JSON.print(io, "functionName") |
|
204 | 210 | write(io, ':') |
|
205 | - | JSON.print(io, node.id) |
|
211 | + | JSON.print(io, node.callFrame.functionName) |
|
206 | 212 | write(io, ',') |
|
207 | - | JSON.print(io, "callFrame") |
|
213 | + | JSON.print(io, "scriptId") |
|
208 | 214 | write(io, ':') |
|
209 | - | write(io, '{') |
|
210 | - | JSON.print(io, "functionName") |
|
211 | - | write(io, ':') |
|
212 | - | JSON.print(io, node.callFrame.functionName) |
|
213 | - | write(io, ',') |
|
214 | - | JSON.print(io, "scriptId") |
|
215 | - | write(io, ':') |
|
216 | - | JSON.print(io, node.callFrame.scriptId) |
|
217 | - | write(io, ',') |
|
218 | - | JSON.print(io, "url") |
|
219 | - | write(io, ':') |
|
220 | - | JSON.print(io, node.callFrame.url) |
|
221 | - | write(io, ',') |
|
222 | - | JSON.print(io, "lineNumber") |
|
223 | - | write(io, ':') |
|
224 | - | JSON.print(io, node.callFrame.lineNumber) |
|
225 | - | write(io, ',') |
|
226 | - | JSON.print(io, "columnNumber") |
|
227 | - | write(io, ':') |
|
228 | - | JSON.print(io, node.callFrame.columnNumber) |
|
229 | - | write(io, '}') |
|
215 | + | JSON.print(io, node.callFrame.scriptId) |
|
230 | 216 | write(io, ',') |
|
231 | - | JSON.print(io, "hitCount") |
|
217 | + | JSON.print(io, "url") |
|
232 | 218 | write(io, ':') |
|
233 | - | JSON.print(io, node.hitCount) |
|
219 | + | JSON.print(io, node.callFrame.url) |
|
234 | 220 | write(io, ',') |
|
235 | - | JSON.print(io, "children") |
|
221 | + | JSON.print(io, "lineNumber") |
|
236 | 222 | write(io, ':') |
|
237 | - | JSON.print(io, node.children) |
|
223 | + | JSON.print(io, node.callFrame.lineNumber) |
|
238 | 224 | write(io, ',') |
|
239 | - | JSON.print(io, "positionTicks") |
|
225 | + | JSON.print(io, "columnNumber") |
|
240 | 226 | write(io, ':') |
|
241 | - | write(io, '[') |
|
242 | - | for (j, tick) in enumerate(node.positionTicks) |
|
243 | - | write(io, '{') |
|
244 | - | JSON.print(io, "line") |
|
245 | - | write(io, ':') |
|
246 | - | JSON.print(io, tick.line) |
|
247 | - | write(io, ',') |
|
248 | - | JSON.print(io, "ticks") |
|
249 | - | write(io, ':') |
|
250 | - | JSON.print(io, tick.ticks) |
|
251 | - | write(io, '}') |
|
252 | - | j == length(node.positionTicks) || write(io, ',') |
|
253 | - | end |
|
254 | - | write(io, ']') |
|
255 | - | write(io, '}') |
|
256 | - | i == length(profile.nodes) || write(io, ',') |
|
257 | - | end |
|
258 | - | write(io, ']') |
|
259 | - | write(io, ',') |
|
260 | - | JSON.print(io, "startTime") |
|
261 | - | write(io, ':') |
|
262 | - | JSON.print(io, profile.startTime) |
|
227 | + | JSON.print(io, node.callFrame.columnNumber) |
|
228 | + | write(io, '}') |
|
263 | 229 | write(io, ',') |
|
264 | - | JSON.print(io, "endTime") |
|
230 | + | JSON.print(io, "hitCount") |
|
265 | 231 | write(io, ':') |
|
266 | - | JSON.print(io, profile.endTime) |
|
232 | + | JSON.print(io, node.hitCount) |
|
267 | 233 | write(io, ',') |
|
268 | - | JSON.print(io, "samples") |
|
234 | + | JSON.print(io, "children") |
|
269 | 235 | write(io, ':') |
|
270 | - | JSON.print(io, profile.samples) |
|
236 | + | JSON.print(io, node.children) |
|
271 | 237 | write(io, ',') |
|
272 | - | JSON.print(io, "timeDeltas") |
|
238 | + | JSON.print(io, "positionTicks") |
|
273 | 239 | write(io, ':') |
|
274 | - | JSON.print(io, profile.timeDeltas) |
|
240 | + | write(io, '[') |
|
241 | + | for (j, tick) in enumerate(node.positionTicks) |
|
242 | + | write(io, '{') |
|
243 | + | JSON.print(io, "line") |
|
244 | + | write(io, ':') |
|
245 | + | JSON.print(io, tick.line) |
|
246 | + | write(io, ',') |
|
247 | + | JSON.print(io, "ticks") |
|
248 | + | write(io, ':') |
|
249 | + | JSON.print(io, tick.ticks) |
|
250 | + | write(io, '}') |
|
251 | + | j == length(node.positionTicks) || write(io, ',') |
|
252 | + | end |
|
253 | + | write(io, ']') |
|
275 | 254 | write(io, '}') |
|
255 | + | i == length(profile.nodes) || write(io, ',') |
|
276 | 256 | end |
|
257 | + | write(io, ']') |
|
258 | + | write(io, ',') |
|
259 | + | JSON.print(io, "startTime") |
|
260 | + | write(io, ':') |
|
261 | + | JSON.print(io, profile.startTime) |
|
262 | + | write(io, ',') |
|
263 | + | JSON.print(io, "endTime") |
|
264 | + | write(io, ':') |
|
265 | + | JSON.print(io, profile.endTime) |
|
266 | + | write(io, ',') |
|
267 | + | JSON.print(io, "samples") |
|
268 | + | write(io, ':') |
|
269 | + | JSON.print(io, profile.samples) |
|
270 | + | write(io, ',') |
|
271 | + | JSON.print(io, "timeDeltas") |
|
272 | + | write(io, ':') |
|
273 | + | JSON.print(io, profile.timeDeltas) |
|
274 | + | write(io, '}') |
|
277 | 275 | nothing |
|
278 | 276 | end |
|
277 | + | ||
278 | + | function save_cpuprofile(filename::AbstractString, data::Union{Nothing, Vector{UInt}} = nothing, |
|
279 | + | period::Union{Nothing, UInt64} = nothing; kwargs...) |
|
280 | + | ||
281 | + | open(filename, "w") do io |
|
282 | + | save_cpuprofile(io, data, period; kwargs...) |
|
283 | + | end |
|
284 | + | end |
Files | Coverage |
---|---|
src/core.jl | 0.00% |
Project Totals (1 files) | 0.00% |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.