MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / main

Function main

benchmarks/benchmarks.cpp:1778–2126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1776
1777
1778int main(int argc, char** argv)
1779{
1780 // Disable buffering (so that when run in, e.g., Sublime Text, the output appears as it is written)
1781 std::setvbuf(stdout, nullptr, _IONBF, 0);
1782
1783 // Isolate the executable name
1784 std::string progName = argv[0];
1785 auto slash = progName.find_last_of("/\\");
1786 if (slash != std::string::npos) {
1787 progName = progName.substr(slash + 1);
1788 }
1789
1790 std::map<std::string, benchmark_type_t> benchmarkMap;
1791 for (int i = 0; i != BENCHMARK_TYPE_COUNT; ++i) {
1792 benchmarkMap.insert(std::make_pair(std::string(BENCHMARK_SHORT_NAMES[i]), (benchmark_type_t)i));
1793 }
1794 std::vector<benchmark_type_t> selectedBenchmarks;
1795
1796 bool showHelp = false;
1797 bool error = false;
1798 bool printedBenchmarks = false;
1799 for (int i = 1; i < argc; ++i) {
1800 if (std::strcmp(argv[i], "-h") == 0 || std::strcmp(argv[i], "--help") == 0) {
1801 showHelp = true;
1802 }
1803 else if (std::strcmp(argv[i], "-p") == 0 || std::strcmp(argv[i], "--precise") == 0) {
1804 precise = true;
1805 }
1806 else if (std::strcmp(argv[i], "--run") == 0) {
1807 if (i + 1 == argc || argv[i + 1][0] == '-') {
1808 std::printf("Expected benchmark name argument for --run option.\n");
1809 if (!printedBenchmarks) {
1810 printBenchmarkNames();
1811 printedBenchmarks = true;
1812 }
1813 error = true;
1814 continue;
1815 }
1816
1817 auto it = benchmarkMap.find(argv[++i]);
1818 if (it == benchmarkMap.end()) {
1819 std::printf("Unrecognized benchmark name '%s'.\n", argv[i]);
1820 if (!printedBenchmarks) {
1821 printBenchmarkNames();
1822 printedBenchmarks = true;
1823 }
1824 error = true;
1825 continue;
1826 }
1827
1828 selectedBenchmarks.push_back(it->second);
1829 }
1830 else {
1831 std::printf("Unrecognized option '%s'\n", argv[i]);
1832 error = true;
1833 }
1834 }
1835 if (showHelp || error) {

Callers

nothing calls this directly

Calls 15

printBenchmarkNamesFunction · 0.85
getCPUStringFunction · 0.85
sayfFunction · 0.85
isvowelFunction · 0.85
randFunction · 0.85
assertClass · 0.85
maxFunction · 0.85
safe_divideFunction · 0.85
prettyFunction · 0.85
timestampFunction · 0.70
insertMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected