From 64250962adbdc0a8eca2e80dee06e72748c25c13 Mon Sep 17 00:00:00 2001 From: Jukka Aho Date: Tue, 11 Apr 2017 10:39:18 +0300 Subject: [PATCH] Use TimerOUtputs.jl to measure time and memory performance - Added TimerOutputs.jl to REQUIRE file - JuliaFEM has now TimerOutput handle `to` and function `print_statistics()` to get summary of time and memory usage - TimerOutputs is used in LinearSolver at the moment and tested in file `test_elasticity_2d_linear_with_surface_load.jl` --- REQUIRE | 1 + src/JuliaFEM.jl | 7 +++++++ src/solvers.jl | 8 ++++---- test/test_elasticity_2d_linear_with_surface_load.jl | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/REQUIRE b/REQUIRE index a352d47..ec768fb 100644 --- a/REQUIRE +++ b/REQUIRE @@ -5,3 +5,4 @@ HDF5 0.7 DataFrames Formatting Logging +TimerOutputs diff --git a/src/JuliaFEM.jl b/src/JuliaFEM.jl index 386e2c4..1c9df7f 100644 --- a/src/JuliaFEM.jl +++ b/src/JuliaFEM.jl @@ -8,6 +8,13 @@ This is JuliaFEM -- Finite Element Package """ module JuliaFEM +using TimerOutputs +const to = TimerOutput() +function print_statistics() + println(to) +end +export print_statistics + import Base: getindex, setindex!, convert, length, size, isapprox, similar, start, first, next, done, last, endof, vec, ==, +, -, *, /, haskey, copy, push!, isempty, empty!, append!, sparse, full, read diff --git a/src/solvers.jl b/src/solvers.jl index 4f14ad2..2339530 100644 --- a/src/solvers.jl +++ b/src/solvers.jl @@ -673,10 +673,10 @@ function (solver::Solver{Linear})() info("Starting linear solver") info("Increment time t=$(round(solver.time, 3))") info(repeat("-", 80)) - initialize!(solver) - assemble!(solver) - solve!(solver) - update!(solver) + @timeit to "initialize solver" initialize!(solver) + @timeit to "assemble problems" assemble!(solver) + @timeit to "solve linear system" solve!(solver) + @timeit to "update problems" update!(solver) t1 = round(Base.time()-t0, 2) info("Linear solver ready in $t1 seconds.") end diff --git a/test/test_elasticity_2d_linear_with_surface_load.jl b/test/test_elasticity_2d_linear_with_surface_load.jl index 4f47455..354db5c 100644 --- a/test/test_elasticity_2d_linear_with_surface_load.jl +++ b/test/test_elasticity_2d_linear_with_surface_load.jl @@ -55,3 +55,5 @@ using JuliaFEM.Testing u3_expected = f/E*[-nu, 1] + g/(2*E)*[-nu, 1] @test isapprox(u3, u3_expected) end + +print_statistics()