Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions benchmarks/src/locate_zone.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "benchmark/benchmark.h"
#include <chrono>

void locate_zone(benchmark::State& state) {
auto&& tzdb = std::chrono::get_tzdb();
for (auto _ : state) {
for (std::size_t i = 0; i != tzdb.zones.size(); ++i) {
auto* res = tzdb.locate_zone(tzdb.zones[i].name());
benchmark::DoNotOptimize(res);
}
}
}

BENCHMARK(locate_zone);

BENCHMARK_MAIN();
5 changes: 3 additions & 2 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -2105,8 +2105,9 @@ namespace chrono {

template <class _Ty>
_NODISCARD const _Ty* _Locate_zone_impl(const vector<_Ty>& _Vec, string_view _Name) {
const auto _Result = _STD find_if(_Vec.begin(), _Vec.end(), [&](auto& _Tz) { return _Tz.name() == _Name; });
return _Result == _Vec.end() ? nullptr : &*_Result;
const auto _Result =
_STD lower_bound(_Vec.begin(), _Vec.end(), _Name, [](auto& _Tz, auto& _Sv) { return _Tz.name() < _Sv; });
return (_Result == _Vec.end() || _Result->name() != _Name) ? nullptr : &*_Result;
}

_EXPORT_STD struct tzdb {
Expand Down