fc15967f8f
- tweaked some CMake option names - moved merge-trace.jl to hosttrace-merge.jl - removed Windows line encodings from hosttrace-merge.jl - improved handling of !perfetto and !timemory
44 lines
1.2 KiB
Julia
Executable File
44 lines
1.2 KiB
Julia
Executable File
#!/usr/bin/env julia
|
|
|
|
using Base: String
|
|
using JSON, DataFrames, Dates, CSV
|
|
|
|
function check_input_args()
|
|
message = "Needs only one json file and at least one trace data file(s)."
|
|
@assert length(ARGS) >= 2 && occursin(".json", join(ARGS)) message
|
|
json_file, trace_files = nothing, String[]
|
|
for arg in ARGS
|
|
@assert Base.Filesystem.ispath(arg) "'$(arg)' not found!"
|
|
if endswith(arg, ".json")
|
|
json_file = arg
|
|
else
|
|
push!(trace_files, arg)
|
|
end
|
|
end
|
|
json_file, trace_files
|
|
end
|
|
|
|
json_file, trace_files = check_input_args()
|
|
|
|
out = JSON.parsefile(json_file)
|
|
for trace in trace_files
|
|
@info "processing $(trace) ..."
|
|
f = tempname() * ".json"
|
|
run(`trace_to_text json $trace $f`)
|
|
todo = JSON.parsefile(f)
|
|
out["traceEvents"] = vcat(
|
|
out["traceEvents"],
|
|
get(todo, "traceEvents", [])
|
|
)
|
|
out["systemTraceEvents"] = (*)(
|
|
get(out, "systemTraceEvents", ""),
|
|
get(todo, "systemTraceEvents", "")
|
|
)
|
|
end
|
|
|
|
output_file = replace("$(string(now())).json", ":" => "-")
|
|
open(output_file, "w") do f
|
|
write(f, JSON.json(out))
|
|
@info "output file: $(output_file)"
|
|
end
|