Created
September 25, 2018 14:38
-
-
Save goropikari/1f3d5506f65a06ba63278256d54c5b4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Julia Version 1.0.0\n", | |
"Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)\n", | |
"Platform Info:\n", | |
" OS: Linux (x86_64-pc-linux-gnu)\n", | |
" CPU: Intel(R) Core(TM) i5-4460T CPU @ 1.90GHz\n", | |
" WORD_SIZE: 64\n", | |
" LIBM: libopenlibm\n", | |
" LLVM: libLLVM-6.0.0 (ORCJIT, haswell)\n", | |
"Environment:\n", | |
" JULIA_SHELL = /usr/bin/zsh\n" | |
] | |
} | |
], | |
"source": [ | |
"versioninfo()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"using BenchmarkTools" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"\u001b[32m\u001b[1m Status\u001b[22m\u001b[39m `~/.julia/environments/v1.0/Project.toml`\n", | |
" \u001b[90m [6e4b80f9]\u001b[39m\u001b[37m BenchmarkTools v0.4.1\u001b[39m\n", | |
" \u001b[90m [7073ff75]\u001b[39m\u001b[37m IJulia v1.12.0\u001b[39m\n" | |
] | |
} | |
], | |
"source": [ | |
"]st" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# $\\mathrm{time}(x) + \\mathrm{time}(y) < \\mathrm{time}(x+y)$" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"BenchmarkTools.Trial: \n", | |
" memory estimate: 78.20 KiB\n", | |
" allocs estimate: 2\n", | |
" --------------\n", | |
" minimum time: 665.527 ns (61.76% GC)\n", | |
" median time: 791.880 ns (61.89% GC)\n", | |
" mean time: 928.644 ns (69.11% GC)\n", | |
" maximum time: 175.168 μs (99.69% GC)\n", | |
" --------------\n", | |
" samples: 10000\n", | |
" evals/sample: 383" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"@benchmark v = Vector{Float64}(undef, 10000)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"BenchmarkTools.Trial: \n", | |
" memory estimate: 0 bytes\n", | |
" allocs estimate: 0\n", | |
" --------------\n", | |
" minimum time: 2.829 μs (0.00% GC)\n", | |
" median time: 2.952 μs (0.00% GC)\n", | |
" mean time: 3.201 μs (0.00% GC)\n", | |
" maximum time: 9.150 μs (0.00% GC)\n", | |
" --------------\n", | |
" samples: 10000\n", | |
" evals/sample: 9" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"v = Vector{Float64}(undef, 10000)\n", | |
"@benchmark fill!(v, 100.0)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"BenchmarkTools.Trial: \n", | |
" memory estimate: 78.20 KiB\n", | |
" allocs estimate: 2\n", | |
" --------------\n", | |
" minimum time: 11.046 μs (0.00% GC)\n", | |
" median time: 14.174 μs (0.00% GC)\n", | |
" mean time: 28.475 μs (42.19% GC)\n", | |
" maximum time: 76.135 ms (99.98% GC)\n", | |
" --------------\n", | |
" samples: 10000\n", | |
" evals/sample: 1" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"@benchmark begin\n", | |
" v = Vector{Float64}(undef, 10000)\n", | |
" fill!(v, 100.0)\n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# $\\mathrm{time}(x) + \\mathrm{time}(y) > \\mathrm{time}(x+y)$" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"BenchmarkTools.Trial: \n", | |
" memory estimate: 148.27 KiB\n", | |
" allocs estimate: 9489\n", | |
" --------------\n", | |
" minimum time: 246.750 μs (0.00% GC)\n", | |
" median time: 284.499 μs (0.00% GC)\n", | |
" mean time: 308.342 μs (5.51% GC)\n", | |
" maximum time: 71.376 ms (99.59% GC)\n", | |
" --------------\n", | |
" samples: 10000\n", | |
" evals/sample: 1" | |
] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"v = Vector{Float64}(undef, 10000)\n", | |
"@benchmark for i in 1:10000\n", | |
" v[i] = 100.0\n", | |
"end" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"BenchmarkTools.Trial: \n", | |
" memory estimate: 78.20 KiB\n", | |
" allocs estimate: 2\n", | |
" --------------\n", | |
" minimum time: 12.023 μs (0.00% GC)\n", | |
" median time: 16.631 μs (0.00% GC)\n", | |
" mean time: 32.058 μs (40.89% GC)\n", | |
" maximum time: 77.440 ms (99.93% GC)\n", | |
" --------------\n", | |
" samples: 10000\n", | |
" evals/sample: 1" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"@benchmark begin\n", | |
" v = Vector{Float64}(undef, 10000)\n", | |
" for i in 1:10000\n", | |
" v[i] = 100.0\n", | |
" end\n", | |
"end" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Julia 1.0.0", | |
"language": "julia", | |
"name": "julia-1.0" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"mimetype": "application/julia", | |
"name": "julia", | |
"version": "1.0.0" | |
}, | |
"toc": { | |
"nav_menu": {}, | |
"number_sections": true, | |
"sideBar": true, | |
"skip_h1_title": false, | |
"toc_cell": false, | |
"toc_position": {}, | |
"toc_section_display": "block", | |
"toc_window_display": false | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment