julia - Solutions to the gargantuan Julia interpreter startup time
问题描述
Currently, it takes a few seconds for the Julia interpreter to start on my machine when running any .jl file.
I'm wondering if there is a simple solution to this, such as a way to have a background pool of interpreters ready to execute scripts or a way to make the Julia repl, once opened, execute a .jl file (and possibly do so with the -p argument to properly handle multithreaded scripts) ?
解决方案
I'm wondering if there is a simple solution to this, such as [...] a way to make the Julia repl, once opened, execute a .jl file [...].
You can execute a .jl file in a running Julia REPL with the include() function. For example, to execute a file foo.jl
, enter the Julia REPL and do:
julia> include("test.jl")
The file will then be executed within the REPL. However, this is unlikely to solve your problem, since the file execution will probably take multiple seconds as well. The REPL itself starts quickly, the long execution time stems from Julia taking a long time to load the file.
You can partially address this issue with Revise.jl. Revise.jl is a Julia package that automatically and quickly reloads your imported files and packages when they are edited. Thus, you could mitigate your issue by only having to load the .jl file once at startup. Here is a quick example of using Revise.jl:
julia> Pkg.add("Example")
INFO: Installing Example v0.4.1
INFO: Package database updated
julia> using Revise # importantly, this must come before `using Example`
julia> using Example
julia> hello("world")
"Hello, world"
推荐阅读
- r - R通过选择随机匹配来解决多个匹配
- php - 如何从 Authorize.net “未结算交易” API 中获取客户的电子邮件地址和交易主题?
- python - 如何在测试发现中跳过一些测试用例?
- r - 如何在 RMarkdown 中将 SVG 设置为默认渲染?
- javascript - 按名称 Ramda 对对象进行分组
- google-analytics - 如何在 Google Analytics 目标设置中设置动态网址?
- java - Java中Hashtable的求和值
- java - 在Java中存储加权边缘的有效方法?
- json - 如何在 dio 响应中访问数据 - _JsonMap
- node.js - 为什么我重新启动服务器后,passport.js 不能反序列化用户?