Skip to content

Instantly share code, notes, and snippets.

use strict;
use warnings;
{
package JSON::ObjectFactory;
use Carp;
use Class::Tiny { json => sub { 'JSON::PP'->new } };
use Import::Into;
use JSON::PP ();
@jadeallenx
jadeallenx / json_bench.pl
Created June 23, 2014 02:02
Do some primitive benchmarking on JSON serialization.
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark qw(:all);
use Data::Random::Structure;
use Data::Dumper;
use JSON::PP ();
use JSON::XS ();
from fedora
maintainer Mark Allen <mrallen1@yahoo.com>
run yum -y install perl-Mojolicious
run yum -y cpanminus
run cpanm Games::Dice
run yum install -y git
run git clone https://gist.github.com/mrallen1/44a415c302139af78dde
cmd ["morbo", "44a415c302139af78dde/dice.pl", "&"]
expose 3000

Keybase proof

I hereby claim:

  • I am mrallen1 on github.
  • I am mrallen1 (https://keybase.io/mrallen1) on keybase.
  • I have a public key whose fingerprint is 6E31 B27C 947F 5E14 FBB0 3E84 7989 7F50 13C3 BD57

To claim this, I am signing this object:

$ git clone https://github.com/basho/rebar_riak_core
Cloning into 'rebar_riak_core'...
remote: Counting objects: 230, done.
remote: Total 230 (delta 0), reused 0 (delta 0), pack-reused 230
Receiving objects: 100% (230/230), 53.38 KiB | 0 bytes/s, done.
Resolving deltas: 100% (114/114), done.
Checking connectivity... done.
$ cd rebar_riak_core; make
mkdir -p /Users/mallen/.rebar/templates
cp riak* /Users/mallen/.rebar/templates
$ dev/dev1/bin/demoapp console
Exec: /Users/mallen/github/basho/demoapp/dev/dev1/erts-5.10.3/bin/erlexec -boot /Users/mallen/github/basho/demoapp/dev/dev1/releases/1/demoapp -embedded -config /Users/mallen/github/basho/demoapp/dev/dev1/etc/app.config -args_file /Users/mallen/github/basho/demoapp/dev/dev1/etc/vm.args -- console
Root: /Users/mallen/github/basho/demoapp/dev/dev1
Erlang R16B02-basho6 (erts-5.10.3) [source] [64-bit] [smp:8:8] [async-threads:5] [hipe] [kernel-poll:true]
17:30:32.462 [info] Application lager started on node 'demoapp1@127.0.0.1'
17:30:32.463 [info] Application crypto started on node 'demoapp1@127.0.0.1'
17:30:32.465 [info] Application riak_sysmon started on node 'demoapp1@127.0.0.1'
17:30:32.472 [info] Application os_mon started on node 'demoapp1@127.0.0.1'
17:30:32.472 [info] Application basho_stats started on node 'demoapp1@127.0.0.1'
ping() ->
DocIdx = riak_core_util:chash_key({<<"ping">>, term_to_binary(now())}),
PrefList = riak_core_apl:get_primary_apl(DocIdx, 1, demoapp),
[{IndexNode, _Type}] = PrefList,
riak_core_vnode_master:sync_spawn_command(IndexNode, ping, demoapp_vnode_master).
handle_handoff_command(_Message, _Sender, State) ->
{noreply, State}.
handoff_starting(_TargetNode, State) ->
{true, State}.
handoff_cancelled(State) ->
{ok, State}.
handoff_finished(_TargetNode, State) ->
handle_handoff_command(?FOLD_REQ{foldfun=VisitFun, acc0=Acc0}, _Sender, State) ->
%% eliding details for now. Don't worry, we'll get to them shortly.
Final = lists:foldl(fun magic/2, Acc0, object_list()),
{reply, Final, State}.
-record(riak_core_fold_req_v2, {
foldfun :: fun(),
acc0 :: term(),
forwardable :: boolean(),
opts = [] :: list()}).
-define(FOLD_REQ, #riak_core_fold_req_v2).