forked from google/xls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated rollback of commit 8587977.
PiperOrigin-RevId: 572682815
- Loading branch information
1 parent
39213f4
commit 1e669d4
Showing
32 changed files
with
239 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2023 The XLS Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "xls/common/benchmark_support.h" | ||
|
||
#include <optional> | ||
#include <string> | ||
|
||
#include "benchmark/benchmark.h" | ||
#include "absl/flags/flag.h" | ||
|
||
// Workaround absl and benchmark:: fighting for flags. | ||
// TODO(https://github.com/google/xls/issues/1150): 2023-11-10 We should try to | ||
// remove this workaround at some point. | ||
ABSL_FLAG(std::optional<std::string>, benchmark_filter, std::nullopt, | ||
"regex to select benchmarks to run"); | ||
|
||
namespace xls { | ||
|
||
void RunSpecifiedBenchmarks() { | ||
// Match BENCHMARK_MAIN macro definition of the benchmark MAIN function. | ||
// We don't want to run benchmarks unless some are actually requested and we | ||
// want to always run gtests so we can't use the standard BENCHMARK_MAIN | ||
// macro. This replicates the parts that configure benchmarks and run them | ||
// with our filters. | ||
int fake_argc = 1; | ||
char fake_argv[] = "benchmark"; | ||
char* fake_argv_ptr = &fake_argv[0]; | ||
benchmark::Initialize(&fake_argc, &fake_argv_ptr); | ||
|
||
// Only run benchmarks if requested. | ||
if (absl::GetFlag(FLAGS_benchmark_filter)) { | ||
benchmark::SetBenchmarkFilter(*absl::GetFlag(FLAGS_benchmark_filter)); | ||
benchmark::RunSpecifiedBenchmarks(); | ||
} | ||
benchmark::Shutdown(); | ||
} | ||
} // namespace xls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2023 The XLS Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef XLS_COMMON_BENCHMARK_SUPPORT_H_ | ||
#define XLS_COMMON_BENCHMARK_SUPPORT_H_ | ||
|
||
namespace xls { | ||
// Helper to perform setup and execute benchmarks. Not a public API. | ||
// This should be called after parsing all flags and setting up googletest. | ||
void RunSpecifiedBenchmarks(); | ||
} // namespace xls | ||
|
||
#endif // XLS_COMMON_BENCHMARK_SUPPORT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2023 The XLS Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "xls/common/gunit_init_xls.h" | ||
|
||
#include "gtest/gtest.h" | ||
#include "xls/common/init_xls.h" | ||
|
||
namespace xls { | ||
|
||
std::vector<std::string_view> InitXlsForTest(std::string_view usage, int argc, | ||
char* argv[]) { | ||
// InitGoogleTest calls ParseAbslFlags with gtest configured to use absl (like | ||
// we do). | ||
testing::InitGoogleTest(&argc, argv); | ||
|
||
internal::InitXlsPostAbslFlagParse(); | ||
|
||
return std::vector<std::string_view>(argv + 1, argv + argc); | ||
} | ||
} // namespace xls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2023 The XLS Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef XLS_COMMON_GUNIT_INIT_XLS_H_ | ||
#define XLS_COMMON_GUNIT_INIT_XLS_H_ | ||
|
||
#include <string_view> | ||
#include <vector> | ||
|
||
namespace xls { | ||
|
||
// Initializes global state in the test, including things like command line | ||
// flags, symbolizer etc. This function might exit the program, for example if | ||
// the command line flags are invalid or if a '--help' command line argument was | ||
// provided. | ||
// | ||
// Is typically called early on in main(). | ||
// | ||
// It must be called after InitGoogleTest | ||
// | ||
// `usage` provides a short usage message usable by | ||
// absl::SetProgramUsageMessage(). | ||
// | ||
// `argc` and `argv` are the command line flags to parse. This function does not | ||
// modify `argc`. | ||
// | ||
// Returns a vector of the positional arguments that are not part of any | ||
// command-line flag (or arguments to a flag), not including the program | ||
// invocation name. (This includes positional arguments after the | ||
// flag-terminating delimiter '--'.) | ||
std::vector<std::string_view> InitXlsForTest(std::string_view usage, int argc, | ||
char* argv[]); | ||
|
||
} // namespace xls | ||
|
||
#endif // XLS_COMMON_GUNIT_INIT_XLS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.