]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
restore formatting flags after use
authorMatthew Barr <matthew.barr@intel.com>
Mon, 19 Jun 2017 05:52:08 +0000 (15:52 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Mon, 21 Aug 2017 01:19:20 +0000 (11:19 +1000)
examples/patbench.cc

index f82f47a737a0b168b2e0aff767a2438e3a22daae..20de5745ee2890def858cd9433cdbf81923d988c 100644 (file)
@@ -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<size_t>(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) {