Skip to content

Instantly share code, notes, and snippets.

@ourway
Created March 22, 2023 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ourway/a0c85634fb49ca295e4d8b7abedad500 to your computer and use it in GitHub Desktop.
Save ourway/a0c85634fb49ca295e4d8b7abedad500 to your computer and use it in GitHub Desktop.
defmodule GFLOPS do
def calculate do
num_iterations = 1_000_000_000
start_time = :erlang.monotonic_time()
for _ <- 1..num_iterations do
# Perform a double-precision floating point operation
_ = 1.0 + 1.0
end
end_time = :erlang.monotonic_time()
elapsed_time = end_time - start_time
gflops = (num_iterations * 2.0) / elapsed_time
IO.puts("GFLOPS: #{gflops}")
end
end
GFLOPS.calculate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment