LoginSignup
8
2

More than 3 years have passed since last update.

PelemayのサンプルDemoを動かしてみる

Last updated at Posted at 2019-09-12

はじめに

$ elixir -v
Erlang/OTP 22 [erts-10.4.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.9.0 (compiled with Erlang/OTP 22)

Demoをやってみる

$ git clone https://github.com/zeam-vm/pelemay.git
$ cd pelemay/
$ mix deps.get
$ mix bench
()
## LogisticMapBench
benchmark na iterations   average time 
Accelerated        5000   739.98 µs/op
Enum               1000   1566.13 µs/op
Flow                500   3899.45 µs/op
  • 実行しているマシンが違うので結果はYouTubeとは違いますが傾向は同じなので成功でしょう
    • git clone しかしていないような……
    • いやいや mix bench なるものははじめて知ったし、「人類にとっては小さな一歩だが、@torifukukaiouにとっては大きな飛躍である!」
      • あれ!?
  • 私が実行しているマシン
    • macOS Mojave バージョン 10.14.6
    • MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)
    • プロセッサ 2.5GHz Intel Core i7
    • メモリ 16 GB 2133 MHz LPDDR3
    • グラフィックス Intel Iris Plus Graphics 640 1536 MB

少し中身をみてみる

diff --git a/lib/sample.ex b/lib/sample.ex
index ca73ee0..855d56c 100644
--- a/lib/sample.ex
+++ b/lib/sample.ex
@@ -20,34 +20,6 @@ defmodule Sample do

   defpelemay do
-    def list_minus_2(list) do
-      list
-      |> Enum.map(&(&1 - 2))
-    end
-
-    def list_plus_2(list) do
-      list
-      |> Enum.map(fn x -> x + 2 end)
-    end
-
-    def list_mult_2(list) do
-      list
-      |> Enum.map(fn x -> x * 2 end)
-    end
-
-    def list_div_2(list) do
-      list
-      |> Enum.map(&(&1 / 2))
-    end
-
-    def list_mod_2(list) do
-      list |> Enum.map(&rem(&1, 2))
-    end
-
-    def list_mod2_plus1(list) do
-      list |> Enum.map(&(rem(&1, 2) + 1))
-    end
-
     def logistic_map(list) do
       list
       |> Enum.map(&rem(22 * &1 * (&1 + 1), 6_700_417))
  • 余りを計算することを繰り返しているとおもうのですが、6700417ってなにだろう?

  • bench/logistic_map_bench.exs にベンチマーク用のコードが書いてある

8
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
2