-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark_traj_3D.jl
More file actions
65 lines (58 loc) · 1.8 KB
/
Copy pathbenchmark_traj_3D.jl
File metadata and controls
65 lines (58 loc) · 1.8 KB
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
@info "benchmark trajectory_julia"
using Distributed
using BenchmarkTools
using Profile
using Logging
logger = ConsoleLogger(stdout, Logging.Debug)
global_logger(logger)
#addprocs(1)
@everywhere push!(LOAD_PATH, "./Fields")
@everywhere push!(LOAD_PATH, "./TrajSolver")
@everywhere push!(LOAD_PATH, "./TrajAnalyzer")
using Fields
using TrajSolver
using TrajAnalyzer
using YAML
include("fileio.jl")
config = YAML.load(open("./test3D.yml"))
fields_config = config["fields-config"]
@info "Read test field."
sfn = Fields.buildAndAlign(fields_config["field"],0,name=ascii([k for k in keys(fields_config)][1]))
Fields.init_parallel!(sfn)
range = [-150.0, 150.0, -150.0, 150.0]
#range = [-1.0, 1.0, -1.0, 1.0]
function benchmark_value(range,t)
xx = range[1]:1.0:range[2]
yy = range[3]:1.0:range[4]
output = zeros(Float64,(length(xx),length(yy)))
for x in enumerate(xx), y in enumerate(yy)
output[x[1],y[1]] = Fields.value([x[2],y[2]],t)
end
return output
end
function benchmark_gradient(range,t)
xx = range[1]:1.0:range[2]
yy = range[3]:1.0:range[4]
output = zeros(Float64,(6,length(xx),length(yy)))
for x in enumerate(xx), y in enumerate(yy)
posvel = Float64[x[2],y[2],0.0,0.0,0.0,0.0]
grad = zeros(Float64,6)
Fields.gradient!(t,posvel,grad,Fields.fields)
output[:,x[1],y[1]] = grad
end
return output
end
#benchmark_value(range,0.0)
benchmark_gradient(range,0.0)
@time benchmark_gradient(range,0.0)
Profile.clear()
Profile.clear_malloc_data()
#@profile benchmark_value(range,0.0)
@info "profiling..."
#benchmark_gradient(range,0.0)
@profile benchmark_gradient(range,0.0)
#using ProfileView
#ProfileView.view()
#@time benchmark_gradient(range,0.0)
#@btime Fields.value([10.0,5.0],0.0)
#@btime Fields.gradient!(0.0,[10.0,5.0,0.0,0.0],zeros(Float64,4),sfn)