2 require '../oils_header.pl';
3 use vars qw/ $authtoken /;
4 use strict; use warnings;
5 use Time::HiRes qw/time usleep/;
7 #------------------------------------------------------------------------
8 err("\nusage: $0 <config> <oils_login_username> ".
9 "<oils_login_password> <patronid> <barcode_file> ".
10 "<num_iterations> <num_processes> <barcode_file> ".
11 "is a file with a single copy barcode per line") unless $ARGV[6];
12 #------------------------------------------------------------------------
26 $numprocs = ($numprocs and $numprocs < 50) ? $numprocs : 1;
28 print "start time = " . time . "\n";
31 for(1..($numprocs - 1)) {
34 sleep(2); # this gives auth time to work
41 my $barcode = $BARCODES[$index];
44 osrf_connect($config);
45 oils_login($username, $password);
47 printl("$$ running barcode $barcode");
53 my $key = do_permit($patronid, $barcode );
54 die "permit failed\n" unless $key;
55 do_checkout($key, $patronid, $barcode );
56 printl("checkout time = " . (time - $start));
59 printl("checkin time = " . (time - $start));
62 print "\nchild $index, iterations = $numiters, ".
63 "total time = " . (time - $s) . ", current time = " . time . "\n";
66 #----------------------------------------------------------------
69 my( $patronid, $barcode ) = @_;
71 my $args = { patron => $patronid, barcode => $barcode };
74 CIRC(), 'open-ils.circ.checkout.permit', $authtoken, $args );
76 oils_event_die($resp);
78 if( ref($resp) eq 'ARRAY' ) { # we received a list of non-success events
79 printl("received event: ".$_->{textcode}) for @$resp;
83 return $resp->{payload};
88 my( $key, $patronid, $barcode ) = @_;
89 my $args = { permit_key => $key, patron => $patronid, barcode => $barcode };
90 my $resp = osrf_request(
92 'open-ils.circ.checkout', $authtoken, $args );
93 oils_event_die($resp);
99 my $args = { barcode => $barcode };
100 my $resp = simplereq(
101 CIRC(), 'open-ils.circ.checkin', $authtoken, $args );
102 oils_event_die($resp);
103 debug($resp) if(ref($resp) eq 'ARRAY');