New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Elixir language to benchmark code #2

Open
wants to merge 4 commits into
from

Conversation

Projects
None yet
5 participants
@webcoyote

Hello Stephen,

This pull request includes support for Elixir, a Ruby-like language built on the Erlang BEAM virtual machine.

two-queues-3
[note: updated image based on results from message-send optimization checked in during a later commit]

I hugely enjoyed your two-queues article. I discovered a lot of new knowledge by reading both the article and code. Until now I hadn't written any Python, Go, or Elixir, so this was a great learning project for all three languages.

The Elixir code is not complete ("--host" not implemented), and I don't support "channels" the same way your code does as actors and channels solve the problem a bit differently (and I'm still learning Elixir). But I thought you might be interested anyway.

It's also only tested on CentOS at present, and the helper scripts I added to install the pre-reqs may need tweaking on OSX.

Please don't feel any need to integrate these changes -- I expect it would make the article and code less useful for readers because they'll have to get Elixir/Erlang working too. I just wanted to share because the code was fun to write and might be valuable to others.

Oh, and finally, in some ways the Elixir code isn't a fair comparison because it isn't sending the messages over sockets, though that aspect of Erlang/BEAM is a reason that it's compelling to use for server development.

Best,

Pat
blog: Code of Honor

@stephenmcd

This comment has been minimized.

Show comment
Hide comment
@stephenmcd

stephenmcd Mar 5, 2013

Owner

Thanks Pat, this is super cool!

I probably won't merge it, since the repo is mostly just meant to represent the state of the blog post - but what I might do is add an update to both the README here and the blog post that links to this pull request at least, so people can have a look at it.

Thanks again - really cool stuff.

Owner

stephenmcd commented Mar 5, 2013

Thanks Pat, this is super cool!

I probably won't merge it, since the repo is mostly just meant to represent the state of the blog post - but what I might do is add an update to both the README here and the blog post that links to this pull request at least, so people can have a look at it.

Thanks again - really cool stuff.

@webcoyote

This comment has been minimized.

Show comment
Hide comment
@webcoyote

webcoyote Mar 5, 2013

Great, thanks!

Great, thanks!

@stephenmcd

This comment has been minimized.

Show comment
Hide comment
@stephenmcd

stephenmcd Mar 5, 2013

Owner

Done here: ccb9588

Owner

stephenmcd commented Mar 5, 2013

Done here: ccb9588

@leoluk

This comment has been minimized.

Show comment
Hide comment
@leoluk

leoluk Mar 7, 2013

Maybe open a branch for such additions?

leoluk commented Mar 7, 2013

Maybe open a branch for such additions?

@josevalim

This comment has been minimized.

Show comment
Hide comment
@josevalim

josevalim Mar 8, 2013

This is great work and I am super excited with the results!
If you don't mind, I will add some comments regarding the Elixir code. :)

This is great work and I am super excited with the results!
If you don't mind, I will add some comments regarding the Elixir code. :)

Show outdated Hide outdated lib/app.ex
messages = Metrics.get_messages
# Get the median messages per second
messages = :lists.sort messages

This comment has been minimized.

@josevalim

josevalim Mar 8, 2013

You can also use the Enum module most of the cases you need to use Erlang's :lists:

@josevalim

josevalim Mar 8, 2013

You can also use the Enum module most of the cases you need to use Erlang's :lists:

Show outdated Hide outdated lib/app.ex
# Note the dash-to-underscore conversion by OptionParser:
# ex: --num-clients => :"num_clients"
:"num_clients" -> args = Dict.put args, key, parse_int(key, val)

This comment has been minimized.

@josevalim

josevalim Mar 8, 2013

You cannot change the binding inside of function. This means that, setting args inside this function, is not going to change the external args. You probably want to use Enum.reduce args, args, fn { key, val }, acc -> instead of Enum.each.

@josevalim

josevalim Mar 8, 2013

You cannot change the binding inside of function. This means that, setting args inside this function, is not going to change the external args. You probably want to use Enum.reduce args, args, fn { key, val }, acc -> instead of Enum.each.

Show outdated Hide outdated lib/app.ex
end
# Set default values
args = Dict.put_new args, :"num_clients", default_num_clients

This comment has been minimized.

@josevalim

josevalim Mar 8, 2013

Those atoms don't need quoting, :num_clients will be fine (if it is a valid function name, it is a valid atom name). :)

@josevalim

josevalim Mar 8, 2013

Those atoms don't need quoting, :num_clients will be fine (if it is a valid function name, it is a valid atom name). :)

end
defmodule Publisher do

This comment has been minimized.

@josevalim

josevalim Mar 8, 2013

You may want to use GenServer.Behaviour so you get all the necessary functions implemented.

@josevalim

josevalim Mar 8, 2013

You may want to use GenServer.Behaviour so you get all the necessary functions implemented.

@webcoyote

This comment has been minimized.

Show comment
Hide comment

Fixed!

@unbalancedparentheses

This comment has been minimized.

Show comment
Hide comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment