X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd%2Ftst-qf.c;h=817a0ceb96a35bdf8c4d8c1273e824c6cb57a20a;hb=063d8a2ddca1e35efde7a3dec5eb04387dfb0922;hp=1d8343b68454cae333d56257734d0c55278805fa;hpb=8847829f22135d594241a9c51877966e7cb0716a;p=apps%2Fpfixtools.git diff --git a/postlicyd/tst-qf.c b/postlicyd/tst-qf.c index 1d8343b..817a0ce 100644 --- a/postlicyd/tst-qf.c +++ b/postlicyd/tst-qf.c @@ -16,17 +16,20 @@ /* products derived from this software without specific prior written */ /* permission. */ /* */ -/* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. */ +/* THIS SOFTWARE IS PROVIDED BY THE 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 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. */ +/* */ +/* Copyright (c) 2006-2008 the Authors */ +/* see AUTHORS and source files for details */ /******************************************************************************/ /* @@ -88,18 +91,30 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - static const char *format = "${sender} ${recipient} and ${client_name}[${client_address}] at ${protocol_state}"; - - time_t now = time(0); - - char str[BUFSIZ]; - static const int iterations = 10000000; - for (int i = 0 ; i < iterations ; ++i) { - query_format(str, BUFSIZ, format, &q); + static const int iterations = 50000000; + { + static const char *format = "${sender} ${recipient} and ${client_name}[${client_address}] at ${protocol_state}"; + time_t now = time(0); + char str[BUFSIZ]; + for (int i = 0 ; i < iterations ; ++i) { + query_format(str, BUFSIZ, format, &q); + } + time_t ellapsed = time(0) - now; + printf("Done %d iterations in %us (%d format per second)\n", iterations, + (uint32_t)ellapsed, (int)(iterations / ellapsed)); } - time_t ellapsed = time(0) - now; - printf("Done %d iterations in %us (%d format per second)\n", iterations, - (uint32_t)ellapsed, (int)(iterations / ellapsed)); + { + time_t now = time(0); + char str[BUFSIZ]; + for (int i = 0 ; i < iterations ; ++i) { + snprintf(str, BUFSIZ, "%s %s and %s[%s] at %s", + q.sender.str, q.recipient.str, q.client_name.str, q.client_address.str, + smtp_state_names[q.state].str); + } + time_t ellapsed = time(0) - now; + printf("Done %d iterations in %us (%d format per second)\n", iterations, + (uint32_t)ellapsed, (int)(iterations / ellapsed)); + } return 0; }