Þ ¥bonds€¬cell_resultsŠÙ$5d2b13be-3d35-11eb-2e47-51223a2a47bfŠ¦queuedÂ¤logs�§runningÂ¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚým1ò°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$5d2b13be-3d35-11eb-2e47-51223a2a47bf¹depends_on_disabled_cellsÂ§runtimeÎ .T·µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$fac02af2-3d34-11eb-17b8-61505c641f17Š¦queuedÂ¤logs‘ˆ¤lineÿ£msg’¥Helloªtext/plain§cell_idÙ$fac02af2-3d34-11eb-17b8-61505c641f17¦kwargs‘’¦rand()’²0.3362369120617531ªtext/plain¢id¹Main_workspace#2_a49d2178¤fileÙj/home/runner/work/disorganised-mess/disorganised-mess/throttled.jl#==#dde97532-3d34-11eb-030d-054b47086952¥group©throttled¥level¤Info§runningÂ¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚým�~°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$fac02af2-3d34-11eb-17b8-61505c641f17¹depends_on_disabled_cellsÂ§runtimeÎþ�µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$880ba494-3b1f-4d1d-95b4-469a7178726cŠ¦queuedÂ¤logs�§runningÂ¦output†¤bodyÙ9<div class="markdown"><h1>With cooldown delay</h1>
</div>¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚýjÐÐ°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$880ba494-3b1f-4d1d-95b4-469a7178726c¹depends_on_disabled_cellsÂ§runtimeÎ ù½µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$8f92a451-694f-41e3-8483-61b7fd26e3ebŠ¦queuedÂ¤logs�§runningÂ¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚýjÐó0°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$8f92a451-694f-41e3-8483-61b7fd26e3eb¹depends_on_disabled_cellsÂ§runtimeÎ Dµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$0aec4a64-3d35-11eb-3d3b-a306558f610cŠ¦queuedÂ¤logs�§runningÂ¦output†¤body³0.03041815757751465¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚým@¼Ü°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$0aec4a64-3d35-11eb-3d3b-a306558f610c¹depends_on_disabled_cellsÂ§runtimeÎÐ“éµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$bf71daae-3d34-11eb-1ca1-d9b018e99f18Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÚ•<div class="pluto-docs-binding">
<span id="throttled">throttled</span>
<div class="markdown"><p>Create a throttled function, which calls the given function <code>f</code> at most once per given interval <code>max_delay</code>.</p>
<p>It is <em>leading</em> &#40;<code>f</code> is invoked immediately&#41; and <em>not trailing</em> &#40;calls during a cooldown period are ignored&#41;.</p>


</div>
</div>
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚýlà�ü°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$bf71daae-3d34-11eb-1ca1-d9b018e99f18¹depends_on_disabled_cellsÂ§runtimeÎ `dµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$dde97532-3d34-11eb-030d-054b47086952Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÙ$log (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚýlíäq°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$dde97532-3d34-11eb-030d-054b47086952¹depends_on_disabled_cellsÂ§runtimeÎ kÒ¬µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$8a1a1300-5f32-445b-8ead-53e700fa186cŠ¦queuedÂ¤logs�§runningÂ¦output†¤bodyÚ8<div class="pluto-docs-binding">
<span id="throttled2">throttled2</span>
<div class="markdown"><p>Create a throttled function, which calls the given function <code>f</code> at most once per given interval <code>max_delay</code>.</p>
<p>It is <em>leading</em> &#40;<code>f</code> is invoked immediately&#41; and <em>not trailing</em> &#40;calls during a cooldown period are ignored&#41;.</p>
<p>An optional third argument sets an initial cooldown period, default is <code>0</code>. With a non-zero value, the throttle is no longer <em>leading</em>.</p>


</div>
</div>
¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚým@ÿ½°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$8a1a1300-5f32-445b-8ead-53e700fa186c¹depends_on_disabled_cellsÂ§runtimeÎ Ë•µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$55752812-3d35-11eb-3962-91f60f0b8219Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÙ##1 (generic function with 1 method)¤mimeªtext/plain¬rootassignee¡t²last_run_timestampËAÚým0ú°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$55752812-3d35-11eb-3962-91f60f0b8219¹depends_on_disabled_cellsÂ§runtimeÍGÚµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$8872d171-f63f-4f8f-a17a-19d05e6382c4Š¦queuedÂ¤logs�§runningÂ¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚýjÐáÖ°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$8872d171-f63f-4f8f-a17a-19d05e6382c4¹depends_on_disabled_cellsÂ§runtimeÎ Çµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂ±cell_dependenciesŠÙ$5d2b13be-3d35-11eb-2e47-51223a2a47bf„´precedence_heuristic	§cell_idÙ$5d2b13be-3d35-11eb-2e47-51223a2a47bf´downstream_cells_map€²upstream_cells_map�¡t‘Ù$55752812-3d35-11eb-3962-91f60f0b8219Ù$fac02af2-3d34-11eb-17b8-61505c641f17„´precedence_heuristic	§cell_idÙ$fac02af2-3d34-11eb-17b8-61505c641f17´downstream_cells_map€²upstream_cells_map�£log‘Ù$dde97532-3d34-11eb-030d-054b47086952Ù$880ba494-3b1f-4d1d-95b4-469a7178726c„´precedence_heuristic	§cell_idÙ$880ba494-3b1f-4d1d-95b4-469a7178726c´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$8f92a451-694f-41e3-8483-61b7fd26e3eb„´precedence_heuristic	§cell_idÙ$8f92a451-694f-41e3-8483-61b7fd26e3eb´downstream_cells_map€²upstream_cells_map€Ù$0aec4a64-3d35-11eb-3d3b-a306558f610c„´precedence_heuristic	§cell_idÙ$0aec4a64-3d35-11eb-3d3b-a306558f610c´downstream_cells_map€²upstream_cells_mapƒ¡-�¤time�¤sqrt�Ù$bf71daae-3d34-11eb-1ca1-d9b018e99f18„´precedence_heuristic	§cell_idÙ$bf71daae-3d34-11eb-1ca1-d9b018e99f18´downstream_cells_map�©throttled‘Ù$55752812-3d35-11eb-3962-91f60f0b8219²upstream_cells_map‹¤@doc�¤time�¥Tuple�º#___this_pluto_module_name�¨Function�§nothing�¤Real�¡-�¢>=�¡+�¥Union�Ù$dde97532-3d34-11eb-030d-054b47086952„´precedence_heuristic	§cell_idÙ$dde97532-3d34-11eb-030d-054b47086952´downstream_cells_map�£log’Ù$fac02af2-3d34-11eb-17b8-61505c641f17Ù$55752812-3d35-11eb-3962-91f60f0b8219²upstream_cells_mapŒ´Base.CoreLogging.===�º#___this_pluto_module_name�¤rand�¿Base.CoreLogging.handle_message�²Base.CoreLogging.!�¤Base�Ù#Base.CoreLogging._invoked_shouldlog�¥@info�¾Base.CoreLogging.logging_error�³Base.CoreLogging.>=�Ù'Base.CoreLogging.current_logger_for_env�¸Base.CoreLogging.convert�Ù$8a1a1300-5f32-445b-8ead-53e700fa186c„´precedence_heuristic	§cell_idÙ$8a1a1300-5f32-445b-8ead-53e700fa186c´downstream_cells_map�ªthrottled2�²upstream_cells_map‹¤@doc�¤time�¥Tuple�º#___this_pluto_module_name�¨Function�§nothing�¤Real�¡-�¢>=�¡+�¥Union�Ù$55752812-3d35-11eb-3962-91f60f0b8219„´precedence_heuristic	§cell_idÙ$55752812-3d35-11eb-3962-91f60f0b8219´downstream_cells_map�¡t‘Ù$5d2b13be-3d35-11eb-2e47-51223a2a47bf²upstream_cells_map‚£log‘Ù$dde97532-3d34-11eb-030d-054b47086952©throttled‘Ù$bf71daae-3d34-11eb-1ca1-d9b018e99f18Ù$8872d171-f63f-4f8f-a17a-19d05e6382c4„´precedence_heuristic	§cell_idÙ$8872d171-f63f-4f8f-a17a-19d05e6382c4´downstream_cells_map€²upstream_cells_map€´cell_execution_orderšÙ$bf71daae-3d34-11eb-1ca1-d9b018e99f18Ù$dde97532-3d34-11eb-030d-054b47086952Ù$fac02af2-3d34-11eb-17b8-61505c641f17Ù$55752812-3d35-11eb-3962-91f60f0b8219Ù$5d2b13be-3d35-11eb-2e47-51223a2a47bfÙ$0aec4a64-3d35-11eb-3d3b-a306558f610cÙ$880ba494-3b1f-4d1d-95b4-469a7178726cÙ$8a1a1300-5f32-445b-8ead-53e700fa186cÙ$8872d171-f63f-4f8f-a17a-19d05e6382c4Ù$8f92a451-694f-41e3-8483-61b7fd26e3eb´last_hot_reload_timeË        ©shortpath¬throttled.jl®process_status¥ready¤pathÙB/home/runner/work/disorganised-mess/disorganised-mess/throttled.jl­pluto_version¨v0.19.47®last_save_timeËAÚýjÏ�†ªcell_orderšÙ$bf71daae-3d34-11eb-1ca1-d9b018e99f18Ù$dde97532-3d34-11eb-030d-054b47086952Ù$fac02af2-3d34-11eb-17b8-61505c641f17Ù$55752812-3d35-11eb-3962-91f60f0b8219Ù$5d2b13be-3d35-11eb-2e47-51223a2a47bfÙ$0aec4a64-3d35-11eb-3d3b-a306558f610cÙ$880ba494-3b1f-4d1d-95b4-469a7178726cÙ$8a1a1300-5f32-445b-8ead-53e700fa186cÙ$8872d171-f63f-4f8f-a17a-19d05e6382c4Ù$8f92a451-694f-41e3-8483-61b7fd26e3eb±published_objects€¥nbpkgŠ¯install_time_nsÎžïÈ�¬instantiatedÃ²installed_versions€°terminal_outputs�ªnbpkg_syncÚÇ
[0m[1mInstantiating...[22m
[90m===[39m
[32m[1m  No Changes[22m[39m to `/tmp/jl_EyBhs3/Project.toml`
[32m[1m  No Changes[22m[39m to `/tmp/jl_EyBhs3/Manifest.toml`

[0m[1mResolving...[22m
[90m===[39m
[32m[1m  No Changes[22m[39m to `/tmp/jl_EyBhs3/Project.toml`
[32m[1m  No Changes[22m[39m to `/tmp/jl_EyBhs3/Manifest.toml`

[0m[1mPrecompiling...[22m
[90m===[39m
[32m[1m  Activating[22m[39m new project at `/tmp/jl_EyBhs3`§enabledÃ·restart_recommended_msgÀ´restart_required_msgÀ­busy_packages�¶waiting_for_permissionÂÙ,waiting_for_permission_but_probably_disabledÂ«cell_inputsŠÙ$5d2b13be-3d35-11eb-2e47-51223a2a47bf„§cell_idÙ$5d2b13be-3d35-11eb-2e47-51223a2a47bf¤code£t()¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$fac02af2-3d34-11eb-17b8-61505c641f17„§cell_idÙ$fac02af2-3d34-11eb-17b8-61505c641f17¤code¥log()¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$880ba494-3b1f-4d1d-95b4-469a7178726c„§cell_idÙ$880ba494-3b1f-4d1d-95b4-469a7178726c¤code¿md"""
# With cooldown delay
"""¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÃÙ$8f92a451-694f-41e3-8483-61b7fd26e3eb„§cell_idÙ$8f92a451-694f-41e3-8483-61b7fd26e3eb¤code ¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$0aec4a64-3d35-11eb-3d3b-a306558f610c„§cell_idÙ$0aec4a64-3d35-11eb-3d3b-a306558f610c¤codeÙ1let
	a = time()
	b = sqrt.([200])
	time() - a
end¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$bf71daae-3d34-11eb-1ca1-d9b018e99f18„§cell_idÙ$bf71daae-3d34-11eb-1ca1-d9b018e99f18¤codeÚà"Create a throttled function, which calls the given function `f` at most once per given interval `max_delay`.

It is _leading_ (`f` is invoked immediately) and _not trailing_ (calls during a cooldown period are ignored)."
function throttled(f::Function, max_delay::Real, initial_offset::Real=0)
	local last_run_at = time() - max_delay + initial_offset
	# return f
	() -> begin
		now = time()
		if now - last_run_at >= max_delay
			f()
			last_run_at = now
		end
		nothing
	end
end¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$dde97532-3d34-11eb-030d-054b47086952„§cell_idÙ$dde97532-3d34-11eb-030d-054b47086952¤codeÙ(function log()
	@info "Hello" rand()
end¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$8a1a1300-5f32-445b-8ead-53e700fa186c„§cell_idÙ$8a1a1300-5f32-445b-8ead-53e700fa186c¤codeÚj"Create a throttled function, which calls the given function `f` at most once per given interval `max_delay`.

It is _leading_ (`f` is invoked immediately) and _not trailing_ (calls during a cooldown period are ignored).

An optional third argument sets an initial cooldown period, default is `0`. With a non-zero value, the throttle is no longer _leading_."
function throttled2(f::Function, max_delay::Real, initial_offset::Real=0)
	local last_run_at = time() - max_delay + initial_offset
	# return f
	() -> begin
		now = time()
		if now - last_run_at >= max_delay
			f()
			last_run_at = now
		end
		nothing
	end
end¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$55752812-3d35-11eb-3962-91f60f0b8219„§cell_idÙ$55752812-3d35-11eb-3962-91f60f0b8219¤code¸t = throttled(log, 2, 5)¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$8872d171-f63f-4f8f-a17a-19d05e6382c4„§cell_idÙ$8872d171-f63f-4f8f-a17a-19d05e6382c4¤code ¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂ«notebook_idÙ$f31b129a-4a9e-11f0-149a-1db46dd1d071«in_temp_dirÂ¨metadata€