[llvm] [llvm][Support] Add ExponentialBackoff helper (PR #81206)
Michael Spencer via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 18:34:49 PST 2024
================
@@ -0,0 +1,31 @@
+//===- unittests/ExponentialBackoffTest.cpp -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/ExponentialBackoff.h"
+#include "gtest/gtest.h"
+#include <chrono>
+
+using namespace llvm;
+using namespace std::chrono_literals;
+
+namespace {
+
+TEST(ExponentialBackoffTest, Timeout) {
+ auto Start = std::chrono::steady_clock::now();
+ // Use short enough times that this test runs quickly.
+ ExponentialBackoff Backoff(100ms, 1ms, 10ms);
+ do {
+ } while (Backoff.waitForNextAttempt());
----------------
Bigcheese wrote:
Yeah, I was concerned about edge cases with virtual machines or other weirdness. I locally checked and it seemed reasonable. Thanks.
https://github.com/llvm/llvm-project/pull/81206
More information about the llvm-commits
mailing list