Skip to content

Commit

Permalink
Update plotting script for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
nirmal-suthar committed Aug 2, 2020
1 parent 5d3e831 commit 5b689a6
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
/examples/assets/
/datasets/modelnet/
/benchmarks/bm_*
/benchmarks/pics/
/benchmarks/pics/*
tmp.jl
2 changes: 1 addition & 1 deletion benchmarks/metrics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function run_benchmarks!(benchmarks, x, benchmark_func, device)
end
end

npoint_arr = 2 .^ [4, 8, 10, 12, 14]
npoint_arr = 2 .^ [6, 8, 10, 12, 14]

names = [
"sample_points",
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def run_benchmarks_(benchmarks, x, benchmark_func, device, niters=51):
[0.2, 0.5, 0.9],
[3.0, 2.0, 1.0]])

npoint_arr = 2 ** np.array([4, 8, 10, 12, 14])
npoint_arr = 2 ** np.array([6, 8, 10, 12, 14])

names = [
"chamfer_distance",
Expand Down
73 changes: 64 additions & 9 deletions benchmarks/plot.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Gadfly, DataFrames, Cairo

function read_benchmarks(fname, framework)
function read_bm_transforms(fname, framework)
isfile(fname) || error("given file location $(fname) is invalid")
data = DataFrame(
category = String[],
Expand All @@ -11,17 +11,53 @@ function read_benchmarks(fname, framework)
)
for line in eachline(fname)
raw = split(line)
push!(data,(raw[1], raw[2], raw[3], parse(Int, raw[4]), parse(Float64, raw[5])))
push!(
data,
(
raw[1],
raw[2],
raw[3],
parse(Int, raw[4]),
parse(Float64, raw[5]),
),
)
end
data[!, :framework] .= framework
return data
end

function save_benchmarks(fname, bm, category, xlabel)
function read_bm_metrics(fname)
isfile(fname) || error("given file location $(fname) is invalid")
data = DataFrame(
framework = String[],
category = String[],
device = String[],
transforms = String[],
npoints = Int[],
time_ms = Float64[],
)
for line in eachline(fname)
raw = split(line)
push!(
data,
(
raw[1],
raw[2],
raw[3],
raw[4],
parse(Int, raw[5]),
parse(Float64, raw[6]),
),
)
end
return data
end

function save_benchmarks(fname, bm, xlabel)
# using Theme(background_color = colorant"white")
# as arg in plot to force white background
p = plot(
bm[bm[!,:category] .== category, :],
bm,
xgroup = "transforms",
ygroup = "device",
color = "framework",
Expand All @@ -35,10 +71,29 @@ function save_benchmarks(fname, bm, category, xlabel)
draw(PNG(fname, 40cm, 20cm), p)
end

bm_flux3d = read_benchmarks(joinpath(@__DIR__, "bm_flux3d.txt"), "Flux3D.jl")
bm_kaolin = read_benchmarks(joinpath(@__DIR__, "bm_kaolin.txt"), "Kaolin")
bm_flux3d = read_bm_transforms(joinpath(@__DIR__, "bm_flux3d.txt"), "Flux3D.jl")
bm_kaolin = read_bm_transforms(joinpath(@__DIR__, "bm_kaolin.txt"), "Kaolin")
bm = vcat(bm_flux3d, bm_kaolin)

save_benchmarks(joinpath(@__DIR__,"pics/bm_pcloud.png"), bm, "PointCloud", "No. of points in PointCloud")
save_benchmarks(joinpath(@__DIR__,"pics/bm_trimesh.png"), bm, "TriMesh", "No. of verts in TriMesh")
save_benchmarks(joinpath(@__DIR__,"pics/bm_metrics.png"), bm, "Metrics", "No. of verts in TriMesh")
bm_flux3d_metrics = read_bm_metrics(joinpath(@__DIR__, "bm_flux3d_metrics.txt"))
bm_kaolin_metrics = read_bm_metrics(joinpath(@__DIR__, "bm_kaolin_metrics.txt"))
bm_metrics = vcat(bm_flux3d_metrics, bm_kaolin_metrics)

save_benchmarks(
joinpath(@__DIR__, "pics/bm_pcloud.png"),
bm[bm[!, :category].=="PointCloud", :],
"PointCloud",
"No. of points in PointCloud",
)
save_benchmarks(
joinpath(@__DIR__, "pics/bm_trimesh.png"),
bm[bm[!, :category].=="TriMesh", :],
"TriMesh",
"No. of verts in TriMesh",
)
save_benchmarks(
joinpath(@__DIR__, "pics/bm_metrics.png"),
bm_metrics,
"Metrics",
"No. of verts in TriMesh",
)
Binary file modified docs/src/assets/bm_metrics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5b689a6

Please sign in to comment.