From 9ae449d3be8298b5ef2312383c70c4a4eb47c5aa Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Fri, 3 Apr 2015 10:40:42 +0200 Subject: [PATCH] Add test script + recompile script --- recompile.sh | 11 +++++++++++ test2.php | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 recompile.sh create mode 100644 test2.php diff --git a/recompile.sh b/recompile.sh new file mode 100755 index 0000000..b78b8d6 --- /dev/null +++ b/recompile.sh @@ -0,0 +1,11 @@ + #!/usr/bin/env bash +CONF_FILE="configure" +if [ -e $CONF_FILE ] ; then + ./configure clean +fi +make clean +phpize +./configure --enable-kafka +make +sudo make install + diff --git a/test2.php b/test2.php new file mode 100644 index 0000000..e7bd60a --- /dev/null +++ b/test2.php @@ -0,0 +1,31 @@ +produce($topic, $msg); +echo 'Done', PHP_EOL; +echo 'Listing partitions for topic ', $topic, PHP_EOL +var_dump($kafka->getPartitionsForTopic('eliasTest')); +echo 'Closing, and reopening connection', PHP_EOL +$kafka = new \Kafka("kafka-1:9092,kafka-2:9092"); +echo 'Done... Now selecting partition 2', PHP_EOL; +$kafka->setPartition(2); +$start = microtime(true); +$cons = $kafka->consume($topic, Kafka::OFFSET_BEGIN , Kafka::OFFSET_END); +$end = microtime(true); +$read = count($cons); +printf('Read all %d messages in %fms, or %f per message' . PHP_EOL, + $read, + $end - $start, + $read ? ($end - $start)/$read : 0 +); +echo 'Dumping messages' +var_dump($cons); +echo 'Closing connection', PHP_EOL; +$kafka->disconnect(); +echo 'Done', PHP_EOL;