Created
March 22, 2023 20:07
-
-
Save ourway/a0c85634fb49ca295e4d8b7abedad500 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
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