Created
March 25, 2020 17:36
-
-
Save ceptreee/0c8a4e71ac878bcc2773505107ba6130 to your computer and use it in GitHub Desktop.
This file contains hidden or 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": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Variables\n", | |
" #self#\u001b[36m::Core.Compiler.Const(F0, false)\u001b[39m\n", | |
" N\u001b[36m::Int64\u001b[39m\n", | |
" S\u001b[91m\u001b[1m::Any\u001b[22m\u001b[39m\n", | |
" @_4\u001b[33m\u001b[1m::Union{Nothing, Tuple{Int64,Int64}}\u001b[22m\u001b[39m\n", | |
" i\u001b[36m::Int64\u001b[39m\n", | |
"\n", | |
"Body\u001b[91m\u001b[1m::Any\u001b[22m\u001b[39m\n", | |
"\u001b[90m1 ─\u001b[39m (S = 0.0)\n", | |
"\u001b[90m│ \u001b[39m %2 = (1:N)\u001b[36m::Core.Compiler.PartialStruct(UnitRange{Int64}, Any[Core.Compiler.Const(1, false), Int64])\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m (@_4 = Base.iterate(%2))\n", | |
"\u001b[90m│ \u001b[39m %4 = (@_4 === nothing)\u001b[36m::Bool\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m %5 = Base.not_int(%4)\u001b[36m::Bool\u001b[39m\n", | |
"\u001b[90m└──\u001b[39m goto #4 if not %5\n", | |
"\u001b[90m2 ┄\u001b[39m %7 = @_4::Tuple{Int64,Int64}\u001b[36m::Tuple{Int64,Int64}\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m (i = Core.getfield(%7, 1))\n", | |
"\u001b[90m│ \u001b[39m %9 = Core.getfield(%7, 2)\u001b[36m::Int64\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m %10 = S\u001b[91m\u001b[1m::Any\u001b[22m\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m %11 = Main.f0(1.0)\u001b[91m\u001b[1m::Any\u001b[22m\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m (S = %10 + %11)\n", | |
"\u001b[90m│ \u001b[39m (@_4 = Base.iterate(%2, %9))\n", | |
"\u001b[90m│ \u001b[39m %14 = (@_4 === nothing)\u001b[36m::Bool\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m %15 = Base.not_int(%14)\u001b[36m::Bool\u001b[39m\n", | |
"\u001b[90m└──\u001b[39m goto #4 if not %15\n", | |
"\u001b[90m3 ─\u001b[39m goto #2\n", | |
"\u001b[90m4 ┄\u001b[39m return S\n" | |
] | |
} | |
], | |
"source": [ | |
"f0 = (t) -> t^2\n", | |
"function F0(N)\n", | |
" S = 0.0\n", | |
" for i = 1:N\n", | |
" S += f0(1.0)\n", | |
" end \n", | |
" return S \n", | |
"end\n", | |
"\n", | |
"N = 10\n", | |
"@code_warntype F0(N)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Variables\n", | |
" #self#\u001b[36m::Core.Compiler.Const(F1, false)\u001b[39m\n", | |
" N\u001b[36m::Int64\u001b[39m\n", | |
" S\u001b[36m::Float64\u001b[39m\n", | |
" @_4\u001b[33m\u001b[1m::Union{Nothing, Tuple{Int64,Int64}}\u001b[22m\u001b[39m\n", | |
" i\u001b[36m::Int64\u001b[39m\n", | |
"\n", | |
"Body\u001b[36m::Float64\u001b[39m\n", | |
"\u001b[90m1 ─\u001b[39m (S = 0.0)\n", | |
"\u001b[90m│ \u001b[39m %2 = (1:N)\u001b[36m::Core.Compiler.PartialStruct(UnitRange{Int64}, Any[Core.Compiler.Const(1, false), Int64])\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m (@_4 = Base.iterate(%2))\n", | |
"\u001b[90m│ \u001b[39m %4 = (@_4 === nothing)\u001b[36m::Bool\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m %5 = Base.not_int(%4)\u001b[36m::Bool\u001b[39m\n", | |
"\u001b[90m└──\u001b[39m goto #4 if not %5\n", | |
"\u001b[90m2 ┄\u001b[39m %7 = @_4::Tuple{Int64,Int64}\u001b[36m::Tuple{Int64,Int64}\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m (i = Core.getfield(%7, 1))\n", | |
"\u001b[90m│ \u001b[39m %9 = Core.getfield(%7, 2)\u001b[36m::Int64\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m %10 = S\u001b[36m::Float64\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m %11 = Main.f1(1.0)\u001b[36m::Core.Compiler.Const(1.0, false)\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m (S = %10 + %11)\n", | |
"\u001b[90m│ \u001b[39m (@_4 = Base.iterate(%2, %9))\n", | |
"\u001b[90m│ \u001b[39m %14 = (@_4 === nothing)\u001b[36m::Bool\u001b[39m\n", | |
"\u001b[90m│ \u001b[39m %15 = Base.not_int(%14)\u001b[36m::Bool\u001b[39m\n", | |
"\u001b[90m└──\u001b[39m goto #4 if not %15\n", | |
"\u001b[90m3 ─\u001b[39m goto #2\n", | |
"\u001b[90m4 ┄\u001b[39m return S\n" | |
] | |
} | |
], | |
"source": [ | |
"f1(t) = t^2\n", | |
"function F1(N)\n", | |
" S = 0.0\n", | |
" for i = 1:N\n", | |
" S += f1(1.0)\n", | |
" end \n", | |
" return S \n", | |
"end\n", | |
"\n", | |
"N = 10\n", | |
"@code_warntype F1(N)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Julia 1.3.1", | |
"language": "julia", | |
"name": "julia-1.3" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"mimetype": "application/julia", | |
"name": "julia", | |
"version": "1.3.1" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment