Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#include "core/platform/telemetry_sampling.h"
 
#include "gtest/gtest.h"
 
namespace onnxruntime::test {
namespace {
 
TEST(TelemetrySamplingTest, HonorsBoundaryRates) {
  EXPECT_FALSE(telemetry_internal::ShouldSampleSession("guid", 1, 0.0));
  EXPECT_TRUE(telemetry_internal::ShouldSampleSession("guid", 1, 100.0));
}
 
TEST(TelemetrySamplingTest, SessionDecisionsAreStableAndSampleExpectedFraction) {
  constexpr uint32_t session_count = 100000;
  uint32_t sampled_count = 0;
  for (uint32_t session_id = 0; session_id < session_count; ++session_id) {
    const bool sampled = telemetry_internal::ShouldSampleSession(
        "00000000-0000-0000-0000-000000000001", session_id, 1.0);
    ASSERT_EQ(telemetry_internal::ShouldSampleSession(
                  "00000000-0000-0000-0000-000000000001", session_id, 1.0),
              sampled)
        << session_id;
    sampled_count += sampled ? 1 : 0;
  }
 
  EXPECT_GT(sampled_count, 900u);
  EXPECT_LT(sampled_count, 1100u);
}
 
}  // namespace
}  // namespace onnxruntime::test