Skip to content

Instantly share code, notes, and snippets.

@yuta-imai
Last active December 19, 2015 21:19
Show Gist options
  • Save yuta-imai/6019516 to your computer and use it in GitHub Desktop.
Save yuta-imai/6019516 to your computer and use it in GitHub Desktop.
<?php
require 'vendor/autoload.php';
use Aws\DynamoDb\DynamoDbClient;
$client = DynamoDbClient::factory(array(
'region' => 'us-west-2',
'scheme' => 'http',
#"client.backoff" => false,
'client.backoff.logger' => 'debug',
));
for($i = 0; $i < 50000; $i++){
$id = rand(0,10000000);
$start = microtime_float();
$result = $client->query(array(
'TableName' => 'audience',
'KeyConditions' => array(
'userid' => array(
'AttributeValueList' => array(
array('S' => $id )
),
'ComparisonOperator' => 'EQ'
)
)
));
$end = microtime_float();
$delta = round(($end - $start)*1000,2);
printf ("%s, %s, %s, %s\n", $i, $id, count($result['Items']),$delta);
}
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment