Created
July 13, 2015 15:18
-
-
Save amitmurthy/c583f4dbf19e02498e61 to your computer and use it in GitHub Desktop.
This file contains 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
addprocs(1) | |
@everywhere function echo_on_sock(s, N) | |
while true | |
try | |
read(s, Float64, (N,)) | |
write(s, fill(Float64(myid()), N)) | |
catch e | |
#println("closed by remote $e") | |
return; | |
end | |
end | |
end | |
@everywhere function server() | |
l = listen(10000) | |
while true | |
s=accept(l) | |
Base.disable_nagle(s) | |
N = read(s, Int64) | |
@async echo_on_sock(s, N) | |
end | |
end | |
@spawnat 2 server() | |
function client(N) | |
c = connect("localhost", 10000) | |
write(c, Int64(N)) | |
Base.disable_nagle(c) | |
print("$N : ") | |
tic() | |
for i in 1:10^4 | |
write(c, fill(Float64(myid()), N)) | |
read(c, Float64, (N,)) | |
end | |
t=toq() | |
println(t) | |
close(c) | |
end | |
client(1); | |
for i in 1:6 | |
client(10^(i-1)); | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment