• Stars
    star
    8
  • Rank 2,099,232 (Top 42 %)
  • Language
    Perl
  • License
    Other
  • Created almost 13 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NAME

Parallel::Benchmark - parallel benchmark module

SYNOPSIS

use Parallel::Benchmark;
sub fib {
    my $n = shift;
    return $n if $n == 0 or $n == 1;
    return fib( $n - 1 ) + fib( $n - 2 );
}
my $bm = Parallel::Benchmark->new(
    benchmark => sub {
        my ($self, $id) = @_;
        fib(10);  # code for benchmarking
        return 1; # score
    },
    concurrency => 3,
);
my $result = $bm->run;
# output to STDERR
#  2012-02-18T21:18:17 [INFO] starting benchmark: concurrency: 3, time: 3
#  2012-02-18T21:18:21 [INFO] done benchmark: score 42018, elapsed 3.000 sec = 14005.655 / sec
# $result hashref
# {
#   'elapsed' => '3.000074',
#   'score'   => 42018,
# }

DESCRIPTION

Parallel::Benchmark is parallel benchmark module.

METHODS

  • new(%args)

    create Parallel::Benchmark instance.

      %args:
        benchmark:   CodeRef to benchmark.
        setup:       CodeRef run on child process before benchmark.
        teardown:    CodeRef run on child process after benchmark.
        time:        Int     benchmark running time. default=3
        concurrency: Int     num of child processes. default=1
        debug:       Bool    output debug log.       default=0
    
  • run()

    run benchmark. returns result hashref.

      {
        'stashes' => {
          '1' => { },   # $self->stash of child id==1
          '2' => { },
          ...
        },
        'score'   => 1886,        # sum of score
        'elapsed' => '3.0022655', # elapsed time (sec)
      };
    
  • stash

    HashRef to store some data while processing.

    Child process's stash returns to result on parent process.

      $result = $bm->run;
      $result->{stashes}->{$id}; #= $self->stash on child $id
    
  • halt()

    Halt benchmark on child processes. it means normally exit.

      benchmark => sub {
          my ($self, $id) = @_;
          if (COND) {
             $self->halt("benchmark $id finished!");
          }
          ...
      },
    

EXAMPLES

HTTP GET Benchmark

use LWP::UserAgent;
my $bm = Parallel::Benchmark->new(
    setup => sub {
        my ($self, $id) = @_;
        $self->stash->{ua} = LWP::UserAgent->new;
    },
    benchmark => sub {
        my ($self, $id) = @_;
        my $res = $self->stash->{ua}->get("http://127.0.0.1/");
        $self->stash->{code}->{ $res->code }++;
        return 1;
    },
    teardown => sub {
        my ($self, $id) = @_;
        delete $self->stash->{ua};
    },
    concurrency => 2,
);
my $result = $bm->run();
# {
    'stashes' => {
      '1' => {
        'code' => {
          '200' => 932,
          '500' => 7
        }
      },
      '2' => {
        'code' => {
          '200' => 935,
          '500' => 12
        }
      }
    },
    'score' => 1886,
    'elapsed' => '3.0022655'
  }

AUTHOR

FUJIWARA Shunichiro [email protected]

SEE ALSO

Parallel::ForkManager

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

More Repositories

1

lambroll

lambroll is a minimal deployment tool for AWS Lambda.
Go
330
star
2

stretcher

Deployment tool with consul/serf event notification.
Go
245
star
3

shapeio

Traffic shaper for Golang io.Reader and io.Writer
Go
126
star
4

awslim

A simplified alternative to the AWS CLI for limited use cases.
Go
114
star
5

fluent-agent-hydra

A Fluentd log agent.
Go
108
star
6

tracer

ECS task event/log tracer CLI
Go
95
star
7

tfstate-lookup

Lookup resource attributes in tfstate.
Go
87
star
8

ecsta

ECS Task Assistant tool.
Go
59
star
9

ridge

AWS Lambda HTTP Proxy integration event bridge to Go net/http.
Go
55
star
10

ecrm

A command line tool for managing ECR repositories.
Go
54
star
11

consul-kv-dashboard

Consul KVS based dashboard web application.
Go
49
star
12

fluent-plugin-zabbix

fluentd out plugin to zabbix
Ruby
49
star
13

kinesis-tailf

tail -f command for Amazon Kinesis Stream
Go
38
star
14

go-zabbix-get

zabbix-get compatible command (Golang version)
Go
28
star
15

Rin

Rin is a Redshift data Importer by SQS messaging.
Go
26
star
16

chef-solo-with-capistrano

chef-solo by capistrano
Ruby
26
star
17

cfft

cfft is a testing tool for CloudFront Functions.
Go
26
star
18

nssh

Go
22
star
19

aswrap

AWS assume role credential wrapper
Perl
21
star
20

tfstate-merge

A tool to merge tfstate files.
Ruby
20
star
21

mysql-slave-healthcheck-agent

Go
17
star
22

tuggle

Distributed file mirroring proxy in Consul cluster
Go
16
star
23

zabbix-aggregate-agent

Data aggregator for multiple zabbix-agent
Go
15
star
24

fluent-plugin-suppress

fluentd plugin to suppress same messages.
Ruby
14
star
25

isucon11-f

Vue
13
star
26

raus

Raus: Ranged unique id supplier
Go
12
star
27

MHA-AWS

A support script for MySQL MasterHA which running on Amazon Web Service.
Perl
12
star
28

lamblocal

Go
12
star
29

go-redis-setlock

Like the setlock command using Redis.
Perl
11
star
30

sailtrim

A minimal deployment tool for Amazon Lightsail.
Go
11
star
31

ohai-plugin-consul

Ohai plugin for Consul API
Ruby
10
star
32

maprobe

Mackerel external probe agent
Go
9
star
33

perl-queue-q4pg-lite

simple message queue using PostgreSQL.
Perl
8
star
34

Urume

Perl
7
star
35

AWS-XRay

AWS X-Ray tracing library for Perl5
Perl
6
star
36

isucon11-q

Go
6
star
37

knockrd

HTTP knocker daemon
Go
6
star
38

riex

AWS RI expiration detector
Go
5
star
39

go-amzn-oidc

Validator for x-amzn-oidc-data header values.
Go
5
star
40

sardine

Mackerel plugin metrics aggregator with CloudWatch.
Go
4
star
41

maws-cli

A multiplexing wrapper for aws cli.
Go
4
star
42

isucon5q

C
4
star
43

mackerel-plugin-prometheus-query

Prometheus query plugin for Mackerel
Go
4
star
44

go-simple-kvs

simple and tiny key value store
Go
4
star
45

consul-lock

runs another program with a Consul session/kv locked.
Go
4
star
46

fluent-plugin-imkayac

Fluentd plugin to post im.kayac.com
Ruby
4
star
47

iam-policy-finder

iam-policy-finder is finder of AWS IAM Policies.
Go
4
star
48

rrdialer

round robin net dialer.
Go
3
star
49

sirbot

Slack IRC relay bot
Go
3
star
50

Redis-Setlock

Like the setlock command using Redis.
Perl
3
star
51

Acore

Perl
3
star
52

fluent-plugin-firelens-tag-filter

fluent plugin for AWS firelens
Ruby
3
star
53

s32cs

Amazon CloudSearch document uploader via S3 event notification.
Go
3
star
54

go-http-transport-firehose

Go HTTP Transport to dump a request to Firehose
Go
3
star
55

isucon7q

HTML
3
star
56

cfn-lookup

Lookup outputs and exports for CloudFormation stacks.
Go
3
star
57

cloudwatch-to-mackerel

Copy metrics from Amazon CloudWatch to Mackerel.
Go
2
star
58

go-jsqlite

SQL query runner for JSONL
Go
2
star
59

lamux

Lamux is a HTTP multiplexer for AWS Lambda Function aliases.
Go
2
star
60

ssm-lookup

Lookup values in AWS SSM Parameter store.
Go
2
star
61

norikra-listener-mackerel

Norikra listener plugin to post service metrics for Mackerel.
Ruby
2
star
62

Devel-KYTProf-Profiler-Redis-Fast

KYTProf profiler for Redis::Fast
Perl
1
star
63

isucon5

Perl
1
star
64

Plack-Middleware-XRay

Plack middleware for AWS X-Ray tracing
Perl
1
star
65

redisqs

redisqs is a delayed queue manager using Amazon SQS and Redis.
Go
1
star
66

Plack-Middleware-GTop-ProcMem

Plack middleware for mesuring process memory.
Perl
1
star
67

macaroni

macaroni is a reporter for Songmu/horenso.
Go
1
star
68

Plack-Middleware-SetLocalEnv

Set localized environment variables(Perl's %ENV) from the value of PSGI environment.
Perl
1
star
69

ktlog2memcached

KyotoTycoon's slave agent, replicate updates to memcached.
Perl
1
star
70

mkr2oncall-cloudflare-workers

A port of mackerel-to-grafana-oncall for Cloudflare Workers.
TypeScript
1
star
71

Test-UNIXSock

testing UNIX domain socket program
Perl
1
star
72

go-template

Go
1
star
73

distdin

Distribute stdin to multiple sub commands.
Go
1
star
74

mirage-ecs-example

Dockerfile
1
star
75

go-s3concat

Concat S3 objects
Go
1
star
76

lambroll_test

Makefile
1
star
77

p5-dbix-couchlike

Perl
1
star