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
page 20: … protoc command…
I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list)
Typo:...
New
Hello! Thanks for the great book.
I was attempting the Trie (chap 17) exercises and for number 4 the solution provided for the autocorre...
New
I found an issue in Chapter 7 regarding android:backgroundTint vs app:backgroundTint.
How to replicate:
load chapter-7 from zipfile i...
New
When I run the coverage example to report on missing lines, I get:
pytest --cov=cards --report=term-missing ch7
ERROR: usage: pytest [op...
New
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
Book: Programming Phoenix LiveView, page 142 (157/378), file lib/pento_web/live/product_live/form_component.ex, in the function below:
d...
New
Modern Front-End Development for Rails - application does not start after run bin/setup (page xviii)
After some hassle, I was able to finally run bin/setup, now I have started the rails server but I get this error message right when I vis...
New
Modern front-end development for Rails, second edition - Struggling to get the first chapter to work
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New
Other popular topics
Take your Go skills to the next level by learning how to design, develop, and deploy a distributed service. Start from the bare essential...
New
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
From finance to artificial intelligence, genetic algorithms are a powerful tool with a wide array of applications. But you don't need an ...
New
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
New
The V Programming Language
Simple language for building maintainable programs
V is already mentioned couple of times in the forum, but I...
New
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig.
General-purpose programming language and toolchain for maintaini...
New
Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
New
Jan | Rethink the Computer.
Jan turns your computer into an AI machine by running LLMs locally on your computer. It’s a privacy-focus, l...
New
This is a very quick guide, you just need to:
Download LM Studio: https://lmstudio.ai/
Click on search
Type DeepSeek, then select the o...
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
- /onivim
- /typescript
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /flutter
- /vscode
- /ash
- /html
- /opensuse
- /zig
- /deepseek
- /centos
- /php
- /scala
- /react-native
- /lisp
- /sublime-text
- /textmate
- /nixos
- /debian
- /agda
- /deno
- /django
- /kubuntu
- /arch-linux
- /nodejs
- /spring
- /ubuntu
- /revery
- /manjaro
- /diversity
- /julia
- /lua
- /markdown
- /v









