Kosty_Fomin

Untitled

Jan 24th, 2019
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1.  
  2. defmodule ExecutionFunctions do
  3.  
  4. defmodule Variables do
  5. def windowSize do 200000 end
  6. def msgCount do 20000000 end
  7. def sizeOfMessage do 1024 end
  8. end
  9.  
  10. def create_message(n) do
  11. [:binary.bin_to_list(<<rem(n, 256) * Variables.sizeOfMessage>>)]
  12. end
  13.  
  14. def push_message(dict_, id) do
  15. low_id = id - Variables.windowSize
  16. dict_ = dict_ ++ create_message(id)
  17. if low_id >=0 do
  18. dict_
  19. |> List.delete_at(low_id)
  20. end
  21. end
  22. end
  23.  
  24.  
  25. defmodule ExecutionTime do
  26. def time_of(function, args) do
  27. {time, result} = :timer.tc(function, args)
  28. IO.puts "Time: #{time}ms"
  29. IO.puts "Result: #{result}"
  30. end
  31. end
  32.  
  33. for x <- 0..ExecutionFunctions.Variables.msgCount, do: ExecutionTime.time_of(&ExecutionFunctions.push_message/2, [[],x])
Advertisement
Add Comment
Please, Sign In to add comment