eekenpiet
Genetic Algorithms in Elixir: Error in task script from ch11 page 180 ebook version 1.0.2
After running a while the benchee test I got the following error: no function clause matching in Task.async/1
I wrote a script with async/3 which works on Elixir 1.17.3-otp27.
defmodule Pmap do
def pmap(collection,func) do
collection
|> Enum.map(&Task.async(Pmap, func, [&1]))
|> Enum.map(&Task.await(&1))
end
def expensive(x) do
x = x * x
:timer.sleep(1000)
x
end
def inexpensive(x) do
x * x
end
end
data = for x <- 1..100, do: x
Benchee.run(
%{
"pmap, expensive" => fn -> Pmap.pmap(data, :expensive) end,
"pmap, inexpensive" => fn -> Pmap.pmap(data, :inexpensive) end,
"map, expensive" => fn -> Enum.map(data, &(Pmap.expensive(&1))) end,
"map, inexpensive" => fn -> Enum.map(data, &(Pmap.inexpensive(&1))) end
},
memory_time: 2
)
"""
Name ips average deviation median 99th %
map, inexpensive 983.51 K 1.02 μs ±3697.41% 0.89 μs 1.35 μs
pmap, inexpensive 2.46 K 406.45 μs ±15.08% 403.66 μs 557.18 μs
pmap, expensive 0.00200 K 501196.83 μs ±0.07% 501063.27 μs 501968.52 μs
map, expensive 0.00002 K 50099628.15 μs ±0.00% 50099628.15 μs 50099628.15 μs
Comparison:
map, inexpensive 983.51 K
pmap, inexpensive 2.46 K - 399.74x slower +405.43 μs
pmap, expensive 0.00200 K - 492932.24x slower +501195.82 μs
map, expensive 0.00002 K - 49273499.77x slower +50099627.13 μs
Memory usage statistics:
Name average deviation median 99th %
map, inexpensive 1.56 KB ±0.00% 1.56 KB 1.56 KB
pmap, inexpensive 39.62 KB ±0.60% 39.60 KB 39.68 KB
pmap, expensive 40.21 KB ±3.01% 39.60 KB 42.02 KB
map, expensive 1.56 KB ±0.00% 1.56 KB 1.56 KB
Comparison:
map, inexpensive 1.56 KB
pmap, inexpensive 39.62 KB - 25.36x memory usage +38.06 KB
pmap, expensive 40.21 KB - 25.73x memory usage +38.64 KB
map, expensive 1.56 KB - 1.00x memory usage +0 KB
"""
Popular Pragmatic Bookshelf topics
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks”
While running the smoke tests in Chapter 2, I get these...
New
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list)
Typo:...
New
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
When I try the command to create a pair of migration files I get an error.
user=> (create-migration "guestbook")
Execution error (Ill...
New
Hi Jamis,
I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019.
This test doesn’t pass for me:
...
New
Hi Travis! Thank you for the cool book! :slight_smile:
I made a list of issues and thought I could post them chapter by chapter. I’m rev...
New
A Common-Sense Guide to Data Structures and Algorithms, Second Edition by Jay Wengrow @jaywengrow
Hi,
I have the paperback version of t...
New
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
New
When trying to run tox in parallel as explained on page 151, I got the following error:
tox: error: argument -p/–parallel: expected one...
New
@mfazio23
I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New
Other popular topics
If it’s a mechanical keyboard, which switches do you have?
Would you recommend it? Why?
What will your next keyboard be?
Pics always w...
New
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
There’s a whole world of custom keycaps out there that I didn’t know existed!
Check out all of our Keycaps threads here:
https://forum....
New
Start building native Android apps the modern way in Kotlin with Jetpack's expansive set of tools, libraries, and best practices. Learn h...
New
New
Use WebRTC to build web applications that stream media and data in real time directly from one user to another, all in the browser.
...
New
Hi folks,
I don’t know if I saw this here but, here’s a new programming language, called Roc
Reminds me a bit of Elm and thus Haskell. ...
New
If you want a quick and easy way to block any website on your Mac using Little Snitch simply…
File > New Rule:
And select Deny, O...
New
Big O Notation can make your code faster by orders of magnitude. Get the hands-on info you need to master data structures and algorithms ...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /python
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /emacs
- /haskell
- /svelte
- /typescript
- /onivim
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /flutter
- /vscode
- /ash
- /html
- /deepseek
- /opensuse
- /zig
- /centos
- /php
- /scala
- /react-native
- /lisp
- /sublime-text
- /textmate
- /nixos
- /debian
- /agda
- /django
- /deno
- /kubuntu
- /arch-linux
- /nodejs
- /ubuntu
- /spring
- /revery
- /manjaro
- /lua
- /diversity
- /julia
- /markdown
- /quarkus









