Last active
July 18, 2022 14:07
-
-
Save antimon2/d06798110ef6ee0d000c7a7bcd4bb3f9 to your computer and use it in GitHub Desktop.
Enum_with_namespace.jl.ipynb
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": [ | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.019Z", | |
"end_time": "2022-07-18T23:05:55.672000+09:00" | |
}, | |
"trusted": true | |
}, | |
"id": "11567985", | |
"cell_type": "code", | |
"source": "versioninfo()", | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "Julia Version 1.7.3\nCommit 742b9abb4d (2022-05-06 12:58 UTC)\nPlatform Info:\n OS: Linux (x86_64-pc-linux-gnu)\n CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\n WORD_SIZE: 64\n LIBM: libopenlibm\n LLVM: libLLVM-12.0.1 (ORCJIT, skylake)\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"id": "68c6a91b", | |
"cell_type": "markdown", | |
"source": "### 例1. `@enum` の記述だけを含むモジュール(≒名前空間)を定義" | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.021Z", | |
"end_time": "2022-07-18T23:05:56.273000+09:00" | |
}, | |
"trusted": true | |
}, | |
"id": "44e1c7a4", | |
"cell_type": "code", | |
"source": "module Colors\n\n@enum Color RED BLUE\n\nend", | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 2, | |
"data": { | |
"text/plain": "Main.Colors" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.022Z", | |
"end_time": "2022-07-18T23:05:56.629000+09:00" | |
}, | |
"trusted": true | |
}, | |
"id": "8d1880f9", | |
"cell_type": "code", | |
"source": "Colors.Color", | |
"execution_count": 3, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 3, | |
"data": { | |
"text/plain": "Enum Main.Colors.Color:\nRED = 0\nBLUE = 1" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.023Z", | |
"end_time": "2022-07-18T23:05:56.870000+09:00" | |
}, | |
"trusted": true | |
}, | |
"id": "d224c331", | |
"cell_type": "code", | |
"source": "Colors.RED", | |
"execution_count": 4, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 4, | |
"data": { | |
"text/plain": "RED::Color = 0" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.025Z", | |
"end_time": "2022-07-18T23:05:56.870000+09:00" | |
}, | |
"trusted": true | |
}, | |
"id": "cb25c692", | |
"cell_type": "code", | |
"source": "Colors.BLUE", | |
"execution_count": 5, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 5, | |
"data": { | |
"text/plain": "BLUE::Color = 1" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"id": "06916413", | |
"cell_type": "markdown", | |
"source": "### 例2. `@enum` で作った型にプロパティを生やす" | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.026Z", | |
"end_time": "2022-07-18T23:05:56.881000+09:00" | |
}, | |
"trusted": true | |
}, | |
"id": "b3da8239", | |
"cell_type": "code", | |
"source": "module SomeModule\n\nexport Color\n\n@enum Color RED BLUE\n\nfunction Base.getproperty(::Type{Color}, name::Symbol)\n if name ∈ (:RED, :BLUE)\n return getfield(@__MODULE__, name)\n end\n getfield(Color, name)\nend\n\nBase.propertynames(::Type{Color}) = (:RED, :BLUE, fieldnames(typeof(Color))...)\n\nend", | |
"execution_count": 6, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 6, | |
"data": { | |
"text/plain": "Main.SomeModule" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.027Z", | |
"end_time": "2022-07-18T23:05:57.358000+09:00" | |
}, | |
"trusted": true | |
}, | |
"id": "6b82f8cb", | |
"cell_type": "code", | |
"source": "using .SomeModule", | |
"execution_count": 7, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.029Z", | |
"end_time": "2022-07-18T23:05:57.492000+09:00" | |
}, | |
"trusted": true | |
}, | |
"id": "64657218", | |
"cell_type": "code", | |
"source": "Color", | |
"execution_count": 8, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 8, | |
"data": { | |
"text/plain": "Enum Color:\nRED = 0\nBLUE = 1" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.030Z", | |
"end_time": "2022-07-18T23:05:57.994000+09:00" | |
}, | |
"trusted": true | |
}, | |
"id": "e61c8905", | |
"cell_type": "code", | |
"source": "Color.RED", | |
"execution_count": 9, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 9, | |
"data": { | |
"text/plain": "RED::Color = 0" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.032Z", | |
"end_time": "2022-07-18T23:05:57.994000+09:00" | |
}, | |
"scrolled": true, | |
"trusted": true | |
}, | |
"id": "30ba05b7", | |
"cell_type": "code", | |
"source": "Color.BLUE", | |
"execution_count": 10, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 10, | |
"data": { | |
"text/plain": "BLUE::Color = 1" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "### 例2′. `@enum` で作った型にプロパティを生やす(後から動的に、rev.20220716)" | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.033Z", | |
"end_time": "2022-07-18T23:05:58.286000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "macro addenumproperty_rev_20220716(TheEnum)\n quote\n let TheEnum=$(esc(TheEnum))\n TheEnum <: Enum || throw(\"$(Symbol(TheEnum)) is NOT an Enum type.\")\n let names=Symbol.(instances(TheEnum))\n function Base.getproperty(::Type{TheEnum}, name::Symbol)\n if name ∈ names\n return getfield(parentmodule(TheEnum), name)\n end\n getfield(TheEnum, name)\n end\n Base.propertynames(::Type{TheEnum}) = (names..., fieldnames(typeof(TheEnum))...)\n end\n end\n end\nend", | |
"execution_count": 11, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 11, | |
"data": { | |
"text/plain": "@addenumproperty_rev_20220716 (macro with 1 method)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.034Z", | |
"end_time": "2022-07-18T23:05:58.661000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "@macroexpand @addenumproperty_rev_20220716 Colors.Color", | |
"execution_count": 12, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 12, | |
"data": { | |
"text/plain": "quote\n \u001b[90m#= In[11]:3 =#\u001b[39m\n let var\"#49#TheEnum\" = Colors.Color\n \u001b[90m#= In[11]:4 =#\u001b[39m\n var\"#49#TheEnum\" <: Main.Enum || Main.throw(\"$(Main.Symbol(var\"#49#TheEnum\")) is NOT an Enum type.\")\n \u001b[90m#= In[11]:5 =#\u001b[39m\n let var\"#50#names\" = Main.Symbol.(Main.instances(var\"#49#TheEnum\"))\n \u001b[90m#= In[11]:6 =#\u001b[39m\n function (Main.Base).getproperty(::Main.Type{var\"#49#TheEnum\"}, var\"#55#name\"::Main.Symbol)\n \u001b[90m#= In[11]:6 =#\u001b[39m\n \u001b[90m#= In[11]:7 =#\u001b[39m\n if var\"#55#name\" ∈ var\"#50#names\"\n \u001b[90m#= In[11]:8 =#\u001b[39m\n return Main.getfield(Main.parentmodule(var\"#49#TheEnum\"), var\"#55#name\")\n end\n \u001b[90m#= In[11]:10 =#\u001b[39m\n Main.getfield(var\"#49#TheEnum\", var\"#55#name\")\n end\n \u001b[90m#= In[11]:12 =#\u001b[39m\n (Main.Base).propertynames(::Main.Type{var\"#49#TheEnum\"}) = begin\n \u001b[90m#= In[11]:12 =#\u001b[39m\n (var\"#50#names\"..., Main.fieldnames(Main.typeof(var\"#49#TheEnum\"))...)\n end\n end\n end\nend" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.036Z", | |
"end_time": "2022-07-18T23:05:58.669000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "module SomeModule2\n\n# export Color\n\n@enum Color RED BLUE\n\nend", | |
"execution_count": 13, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 13, | |
"data": { | |
"text/plain": "Main.SomeModule2" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.038Z", | |
"end_time": "2022-07-18T23:05:58.693000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "@addenumproperty_rev_20220716 SomeModule2.Color", | |
"execution_count": 14, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.039Z", | |
"end_time": "2022-07-18T23:05:59.698000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "SomeModule2.Color.RED", | |
"execution_count": 15, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 15, | |
"data": { | |
"text/plain": "RED::Color = 0" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"id": "29702ee6", | |
"cell_type": "markdown", | |
"source": "### 例2′′. `@enum` で作った型にプロパティを生やす(後から動的に、パフォーマンス改善版)" | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.040Z", | |
"end_time": "2022-07-18T23:05:59.823000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "macro addenumproperty(enumEx)\n TheEnum = Core.eval(__module__, enumEx)\n TheEnum <: Enum || throw(\"$(Symbol(TheEnum)) is NOT an Enum type.\")\n _instances = instances(TheEnum)\n _names = Symbol.(_instances)\n _name_instance_pairs = Symbol.(_instances) .=> _instances\n var_name = gensym(\"name\")\n blk = Expr(:block, (\n :($var_name === $(QuoteNode(name)) && return $(instance))\n for (name, instance) in _name_instance_pairs\n )...)\n quote\n function Base.getproperty(::Type{$TheEnum}, $var_name::Symbol)\n $blk\n getfield($TheEnum, $var_name)\n end\n Base.propertynames(::Type{$TheEnum}) = ($(QuoteNode.(_names)...), fieldnames(typeof($TheEnum))...)\n end\nend", | |
"execution_count": 16, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 16, | |
"data": { | |
"text/plain": "@addenumproperty (macro with 1 method)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.042Z", | |
"end_time": "2022-07-18T23:05:59.950000+09:00" | |
}, | |
"trusted": true | |
}, | |
"id": "16418760", | |
"cell_type": "code", | |
"source": "@macroexpand @addenumproperty Colors.Color", | |
"execution_count": 17, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 17, | |
"data": { | |
"text/plain": "quote\n \u001b[90m#= In[16]:13 =#\u001b[39m\n function (Main.Base).getproperty(::Main.Type{Main.Colors.Color}, var\"#76###name#291\"::Main.Symbol)\n \u001b[90m#= In[16]:13 =#\u001b[39m\n \u001b[90m#= In[16]:14 =#\u001b[39m\n begin\n var\"#76###name#291\" === :RED && return Main.Colors.RED\n var\"#76###name#291\" === :BLUE && return Main.Colors.BLUE\n end\n \u001b[90m#= In[16]:15 =#\u001b[39m\n Main.getfield(Main.Colors.Color, var\"#76###name#291\")\n end\n \u001b[90m#= In[16]:17 =#\u001b[39m\n (Main.Base).propertynames(::Main.Type{Main.Colors.Color}) = begin\n \u001b[90m#= In[16]:17 =#\u001b[39m\n (:RED, :BLUE, Main.fieldnames(Main.typeof(Main.Colors.Color))...)\n end\nend" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.043Z", | |
"end_time": "2022-07-18T23:05:59.958000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "module SomeModule3\n\n# export Color\n\n@enum Color RED BLUE\n\nend", | |
"execution_count": 18, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 18, | |
"data": { | |
"text/plain": "Main.SomeModule3" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true, | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.044Z", | |
"end_time": "2022-07-18T23:06:00.039000+09:00" | |
} | |
}, | |
"id": "4d67bd98", | |
"cell_type": "code", | |
"source": "@addenumproperty SomeModule3.Color", | |
"execution_count": 19, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.045Z", | |
"end_time": "2022-07-18T23:06:01.031000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "SomeModule3.Color.RED", | |
"execution_count": 20, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 20, | |
"data": { | |
"text/plain": "RED::Color = 0" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "### ベンチマーク" | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.046Z", | |
"end_time": "2022-07-18T23:06:01.292000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "using BenchmarkTools", | |
"execution_count": 21, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.048Z", | |
"end_time": "2022-07-18T23:06:01.628000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "# _propnames = propertynames(SomeModule2.Color)\n_propnames = ((\n name\n for name in propertynames(SomeModule2.Color)\n if name in (:RED, :BLUE) || isdefined(SomeModule2.Color, name)\n)...,)", | |
"execution_count": 22, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 22, | |
"data": { | |
"text/plain": "(:RED, :BLUE, :name, :super, :parameters, :types, :layout, :size, :hash, :flags)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.049Z", | |
"end_time": "2022-07-18T23:06:02.223000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "getproperty.(SomeModule2.Color, _propnames)", | |
"execution_count": 23, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 23, | |
"data": { | |
"text/plain": "(Main.SomeModule2.RED, Main.SomeModule2.BLUE, typename(Main.SomeModule2.Color), Enum{Int32}, svec(), svec(), Ptr{Nothing} @0x00007ffa0c8557f8, 4, -1425321796, 0x6a)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.050Z", | |
"end_time": "2022-07-18T23:06:07.036000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "# @benchmark getproperty(SomeModule2.Color, _name) setup=(_name=rand(propertynames(SomeModule2.Color)))\n@benchmark getproperty(SomeModule2.Color, _name) setup=(_name=rand(_propnames))", | |
"execution_count": 24, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 24, | |
"data": { | |
"text/plain": "BenchmarkTools.Trial: 10000 samples with 997 evaluations.\n Range \u001b[90m(\u001b[39m\u001b[36m\u001b[1mmin\u001b[22m\u001b[39m … \u001b[35mmax\u001b[39m\u001b[90m): \u001b[39m\u001b[36m\u001b[1m19.333 ns\u001b[22m\u001b[39m … \u001b[35m580.939 ns\u001b[39m \u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmin … max\u001b[90m): \u001b[39m0.00% … 0.00%\n Time \u001b[90m(\u001b[39m\u001b[34m\u001b[1mmedian\u001b[22m\u001b[39m\u001b[90m): \u001b[39m\u001b[34m\u001b[1m29.293 ns \u001b[22m\u001b[39m\u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmedian\u001b[90m): \u001b[39m0.00%\n Time \u001b[90m(\u001b[39m\u001b[32m\u001b[1mmean\u001b[22m\u001b[39m ± \u001b[32mσ\u001b[39m\u001b[90m): \u001b[39m\u001b[32m\u001b[1m82.824 ns\u001b[22m\u001b[39m ± \u001b[32m111.171 ns\u001b[39m \u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmean ± σ\u001b[90m): \u001b[39m0.00% ± 0.00%\n\n \u001b[39m█\u001b[39m▇\u001b[34m▄\u001b[39m\u001b[39m▆\u001b[39m▄\u001b[39m▁\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[32m \u001b[39m\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m▆\u001b[39m▄\u001b[39m▂\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m▂\n \u001b[39m█\u001b[39m█\u001b[34m█\u001b[39m\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[32m▇\u001b[39m\u001b[39m▆\u001b[39m▅\u001b[39m▁\u001b[39m▃\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m▇\u001b[39m▇\u001b[39m▆\u001b[39m▅\u001b[39m▇\u001b[39m█\u001b[39m█\u001b[39m▇\u001b[39m▅\u001b[39m▅\u001b[39m \u001b[39m█\n 19.3 ns\u001b[90m \u001b[39m\u001b[90mHistogram: \u001b[39m\u001b[90m\u001b[1mlog(\u001b[22m\u001b[39m\u001b[90mfrequency\u001b[39m\u001b[90m\u001b[1m)\u001b[22m\u001b[39m\u001b[90m by time\u001b[39m 364 ns \u001b[0m\u001b[1m<\u001b[22m\n\n Memory estimate\u001b[90m: \u001b[39m\u001b[33m0 bytes\u001b[39m, allocs estimate\u001b[90m: \u001b[39m\u001b[33m0\u001b[39m." | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2022-07-18T14:05:56.052Z", | |
"end_time": "2022-07-18T23:06:08.010000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "@benchmark getproperty(SomeModule3.Color, _name) setup=(_name=rand(_propnames))", | |
"execution_count": 25, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 25, | |
"data": { | |
"text/plain": "BenchmarkTools.Trial: 10000 samples with 999 evaluations.\n Range \u001b[90m(\u001b[39m\u001b[36m\u001b[1mmin\u001b[22m\u001b[39m … \u001b[35mmax\u001b[39m\u001b[90m): \u001b[39m\u001b[36m\u001b[1m 9.568 ns\u001b[22m\u001b[39m … \u001b[35m99.190 ns\u001b[39m \u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmin … max\u001b[90m): \u001b[39m0.00% … 0.00%\n Time \u001b[90m(\u001b[39m\u001b[34m\u001b[1mmedian\u001b[22m\u001b[39m\u001b[90m): \u001b[39m\u001b[34m\u001b[1m20.901 ns \u001b[22m\u001b[39m\u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmedian\u001b[90m): \u001b[39m0.00%\n Time \u001b[90m(\u001b[39m\u001b[32m\u001b[1mmean\u001b[22m\u001b[39m ± \u001b[32mσ\u001b[39m\u001b[90m): \u001b[39m\u001b[32m\u001b[1m23.849 ns\u001b[22m\u001b[39m ± \u001b[32m10.316 ns\u001b[39m \u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmean ± σ\u001b[90m): \u001b[39m0.00% ± 0.00%\n\n \u001b[39m█\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m▄\u001b[39m▃\u001b[34m \u001b[39m\u001b[39m \u001b[39m \u001b[39m \u001b[32m \u001b[39m\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \n \u001b[39m█\u001b[39m▄\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▁\u001b[39m▃\u001b[39m▇\u001b[39m█\u001b[39m█\u001b[34m▇\u001b[39m\u001b[39m▃\u001b[39m▂\u001b[39m▂\u001b[32m▂\u001b[39m\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▃\u001b[39m█\u001b[39m█\u001b[39m▄\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▃\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▃\u001b[39m▂\u001b[39m▃\u001b[39m▅\u001b[39m▄\u001b[39m▃\u001b[39m▄\u001b[39m▄\u001b[39m▃\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m▂\u001b[39m \u001b[39m▃\n 9.57 ns\u001b[90m Histogram: frequency by time\u001b[39m 49.2 ns \u001b[0m\u001b[1m<\u001b[22m\n\n Memory estimate\u001b[90m: \u001b[39m\u001b[33m0 bytes\u001b[39m, allocs estimate\u001b[90m: \u001b[39m\u001b[33m0\u001b[39m." | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "julia-1.7", | |
"display_name": "Julia 1.7.3", | |
"language": "julia" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"name": "julia", | |
"mimetype": "application/julia", | |
"version": "1.7.3" | |
}, | |
"gist": { | |
"id": "d06798110ef6ee0d000c7a7bcd4bb3f9", | |
"data": { | |
"description": "Enum_with_namespace.jl.ipynb", | |
"public": true | |
} | |
}, | |
"_draft": { | |
"nbviewer_url": "https://gist.github.com/d06798110ef6ee0d000c7a7bcd4bb3f9" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment