Skip to content

Commit

Permalink
rdkafka_performance: fix build warnings on win32-x32
Browse files Browse the repository at this point in the history
and some tidying up
  • Loading branch information
edenhill committed Jun 3, 2019
1 parent 04ab6c2 commit 6e1a8da
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions examples/rdkafka_performance.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
*
* Copyright (c) 2012, Magnus Edenhill
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
Expand Down Expand Up @@ -187,9 +187,8 @@ static void msg_delivered (rd_kafka_t *rk,
static rd_ts_t last;
rd_ts_t now = rd_clock();
static int msgs;
double error_percent = 0;

msgs++;

msgs++;

msgs_wait_cnt--;

Expand All @@ -213,7 +212,7 @@ static void msg_delivered (rd_kafka_t *rk,
(cnt.msgs_dr_err < 50 ||
!(cnt.msgs_dr_err % (dispintvl / 1000)))) ||
!last || msgs_wait_cnt < 5 ||
!(msgs_wait_cnt % dr_disp_div) ||
!(msgs_wait_cnt % dr_disp_div) ||
(now - last) >= dispintvl * 1000 ||
verbosity >= 3) {
if (rkmessage->err && verbosity >= 2)
Expand All @@ -237,12 +236,13 @@ static void msg_delivered (rd_kafka_t *rk,
cnt.last_offset = rkmessage->offset;

if (msgs_wait_produce_cnt == 0 && msgs_wait_cnt == 0 && !forever) {
if (cnt.msgs > 0) {
error_percent = (cnt.msgs - cnt.msgs_dr_ok)/cnt.msgs * 100;
}
if (verbosity >= 2)
printf("Messages delivered with failure percentage of %.5f!\n",
error_percent);
if (verbosity >= 2 && cnt.msgs > 0) {
double error_percent =
(double)(cnt.msgs - cnt.msgs_dr_ok) /
cnt.msgs * 100;
printf("%% Messages delivered with failure "
"percentage of %.5f%%\n", error_percent);
}
t_end = rd_clock();
run = 0;
}
Expand Down

0 comments on commit 6e1a8da

Please sign in to comment.