summaryrefslogtreecommitdiffstats
path: root/server/IptablesRestoreControllerTest.cpp
diff options
context:
space:
mode:
authorBernie Innocenti <codewiz@google.com>2019-05-20 16:34:16 +0900
committerBernie Innocenti <codewiz@google.com>2019-05-29 15:10:48 +0900
commit196f1b8a0f3d64b02a37069c37b35f32d358939a (patch)
tree5b81c54dc25d45856a8f40b98708a7354a174e2f /server/IptablesRestoreControllerTest.cpp
parente48bf0b636f9e0e0330f69ea5798f5bec48ec67e (diff)
downloadplatform_system_netd-196f1b8a0f3d64b02a37069c37b35f32d358939a.tar.gz
platform_system_netd-196f1b8a0f3d64b02a37069c37b35f32d358939a.tar.bz2
platform_system_netd-196f1b8a0f3d64b02a37069c37b35f32d358939a.zip
Remove floating-point time functions from StopWatch
Converting time units between floating-point milliseconds to integral micros and floating-point seconds is error prone and leads to subtle rounding bugs. Thus, consolidate all callers on microseconds and delete the older methods. Test: cd system/netd && atest . Change-Id: Ief6ad4dbd21f442bfd65e78d49548677f3172a53
Diffstat (limited to 'server/IptablesRestoreControllerTest.cpp')
-rw-r--r--server/IptablesRestoreControllerTest.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/server/IptablesRestoreControllerTest.cpp b/server/IptablesRestoreControllerTest.cpp
index d01d7ced1..c9028df1a 100644
--- a/server/IptablesRestoreControllerTest.cpp
+++ b/server/IptablesRestoreControllerTest.cpp
@@ -14,14 +14,16 @@
* limitations under the License.
*/
-#include <string>
#include <fcntl.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
#include <sys/file.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
+#include <cinttypes>
+#include <iostream>
+#include <string>
#define LOG_TAG "IptablesRestoreControllerTest"
#include <android-base/stringprintf.h>
@@ -269,9 +271,9 @@ TEST_F(IptablesRestoreControllerTest, TestUidRuleBenchmark) {
EXPECT_EQ(0, con.execute(V4V6, IPTABLES_RESTORE_ADD, nullptr));
EXPECT_EQ(0, con.execute(V4V6, IPTABLES_RESTORE_DEL, nullptr));
}
- float timeTaken = s.getTimeAndReset();
- fprintf(stderr, " Add/del %d UID rules via restore: %.1fms (%.2fms per operation)\n",
- iterations, timeTaken, timeTaken / 2 / iterations);
+ int64_t timeTaken = s.getTimeAndResetUs();
+ std::cerr << " Add/del " << iterations << " UID rules via restore: " << timeTaken
+ << "us (" << (timeTaken / 2 / iterations) << "us per operation)" << std::endl;
}
}