Julia seems an order of magnitude slower than Python when printing to the terminal, because of issue with "sleep"

This version runs at a decent speed by busy-waiting, so I think the entire problem here is about the ability to sleep for a controlled amount of time.

function main()
    delay = 1e9 / 1200
    data = read(stdin, String)
    base_time = time_ns()
    for (i, b) in enumerate(data)
        print(b)
        while time_ns() < base_time + delay * i
        end
    end
end

main()
6 Likes