Skip to content

Commit

Permalink
Add precompilation (#224)
Browse files Browse the repository at this point in the history
* Add precompilation

On my machine this drops the time required for the "workload" from
about 0.25s to about 0.025s (factor of 10). While the absolute times
are not large, the aim is to reduce the startup time for IJulia kernels.

* Add [compat]

* fix indentation
  • Loading branch information
timholy authored May 7, 2023
1 parent 8378ab3 commit f71c1fc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ version = "1.2.2"

[deps]
FileWatching = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
ZeroMQ_jll = "8f1865be-045e-5c20-9c9f-bfbfb0764568"

[compat]
PrecompileTools = "1"
ZeroMQ_jll = "4"
julia = "1.3"

Expand Down
28 changes: 28 additions & 0 deletions src/ZMQ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,32 @@ function __init__()
end
end

using PrecompileTools
@compile_workload begin
__init__()
# The ZMQ scoping below isn't necessary, but it makes it easier to copy/paste
# the workload to test impact.
s=Socket(PUB)
ZMQ.close(s)

s1=Socket(REP)
s1.sndhwm = 1000
s1.linger = 1
s1.routing_id = "abcd"

s2=Socket(REQ)

ZMQ.bind(s1, "tcp://*:5555")
ZMQ.connect(s2, "tcp://localhost:5555")

msg = Message("test request")

ZMQ.send(s2, msg)
unsafe_string(ZMQ.recv(s1))
ZMQ.send(s1, Message("test response"))
unsafe_string(ZMQ.recv(s2))
ZMQ.close(s1)
ZMQ.close(s2)
end

end

0 comments on commit f71c1fc

Please sign in to comment.