From c7f3150141bc5e1ab5e271feac8d81a185eb78e1 Mon Sep 17 00:00:00 2001 From: Matthew Barr Date: Mon, 19 Jun 2017 15:52:08 +1000 Subject: [PATCH] restore formatting flags after use --- examples/patbench.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/patbench.cc b/examples/patbench.cc index f82f47a7..20de5745 100644 --- a/examples/patbench.cc +++ b/examples/patbench.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016, Intel Corporation + * Copyright (c) 2015-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -165,6 +165,7 @@ static bool higher_is_better(Criterion c) { } static void print_criterion(Criterion c, double val) { + std::ios::fmtflags f(cout.flags()); switch (c) { case CRITERION_THROUGHPUT: cout << std::fixed << std::setprecision(3) << val << " Megabits/s"; @@ -179,6 +180,7 @@ static void print_criterion(Criterion c, double val) { cout << static_cast(val) << " bytes"; break; } + cout.flags(f); } // Key for identifying a stream in our pcap input data, using data from its IP @@ -596,11 +598,13 @@ double eval_set(Benchmark &bench, Sigdata &sigs, unsigned int mode, size_t bytes = bench.bytes(); size_t matches = bench.matches(); if (diagnose) { + std::ios::fmtflags f(cout.flags()); cout << "Scan time " << std::fixed << std::setprecision(3) << scan_time << " sec, Scanned " << bytes * repeatCount << " bytes, Throughput " << std::fixed << std::setprecision(3) << (bytes * 8 * repeatCount) / (scan_time * 1000000) << " Mbps, Matches " << matches << endl; + cout.flags(f); } return (bytes * 8 * repeatCount) / (scan_time * 1000000); } @@ -755,10 +759,12 @@ int main(int argc, char **argv) { for (unsigned i = count; i < 16; i++) { cout << " "; } + std::ios::fmtflags out_f(cout.flags()); cout << "Performance: "; print_criterion(criterion, best); cout << " (" << std::fixed << std::setprecision(3) << (best / score_base) << "x) after cutting:" << endl; + cout.flags(out_f); // s now has factor_max signatures for (const auto &found : s) {