Skip to content

Commit 366f949

Browse files
committed
Refactor and update tests.
1 parent c4a1eef commit 366f949

13 files changed

+249
-118
lines changed

src/config.hpp

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,10 @@
33

44
#pragma once
55

6-
#ifndef _DEBUG
7-
# undef ENABLE_MEMORY_PROFILING
8-
#endif
9-
10-
#ifdef _WIN32
11-
# ifndef WIN32_LEAN_AND_MEAN
12-
# error Requires WIN32_LEAN_AND_MEAN definition
13-
# endif
14-
# ifndef NOMINMAX
15-
# error Requires NOMINMAX definition
16-
# endif
17-
# include <windows.h>
18-
# include <io.h>
19-
# include <fcntl.h>
20-
# include <clocale>
21-
# if defined(ENABLE_MEMORY_PROFILING) && defined(_DEBUG) && (defined(_MSC_VER) || defined(__clang__))
22-
# include <crtdbg.h>
23-
# include <iostream>
24-
# else
25-
# undef ENABLE_MEMORY_PROFILING
26-
# endif
27-
#else
28-
# undef ENABLE_MEMORY_PROFILING
29-
#endif
30-
31-
inline void config_console() {
32-
#ifdef _WIN32
33-
::SetConsoleOutputCP(CP_UTF8);
34-
::SetConsoleCP(CP_UTF8);
35-
::setlocale(LC_ALL, ".UTF8");
36-
#endif
37-
}
38-
39-
inline void config_profiler() {
40-
#ifdef ENABLE_MEMORY_PROFILING
41-
std::cout << "!! Enabled memory profiling !!" << std::endl;
42-
constexpr auto report_mode = /*_CRTDBG_MODE_DEBUG |*/ _CRTDBG_MODE_FILE /*| _CRTDBG_MODE_WNDW*/;
43-
::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);
44-
::_CrtSetReportMode(_CRT_ASSERT, report_mode);
45-
::_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
46-
::_CrtSetReportMode(_CRT_WARN, report_mode);
47-
::_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
48-
::_CrtSetReportMode(_CRT_ERROR, report_mode);
49-
::_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
50-
#endif
51-
}
52-
536
#include "types.hpp"
547
#include <cassert>
55-
#include <thread>
568
#include <algorithm>
9+
#include <thread>
5710

5811
namespace test::config {
5912
struct prelim {

src/stress_test_mpmc_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) 2025 Vitaly Anasenko
22
// Distributed under the MIT License, see accompanying file LICENSE.txt
33

4+
#include "init.hpp"
45
#include "config.hpp"
56
#include "messages.hpp"
67
#include <xtxn/fast_mpmc_queue.hpp>
@@ -17,8 +18,8 @@
1718
#include <iostream>
1819

1920
int main(int, char **) {
20-
config_console();
21-
config_profiler();
21+
init::console();
22+
init::profiler();
2223

2324
const unsigned producers { std::thread::hardware_concurrency() << 2 };
2425
const unsigned consumers { producers };

src/test_fast_mpmc_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Copyright (c) 2025 Vitaly Anasenko
22
// Distributed under the MIT License, see accompanying file LICENSE.txt
33

4+
#include "init.hpp"
45
#include "config.hpp"
56
#include "fast_queue_test.hpp"
67

78
int main(int, char **) {
8-
config_console();
9-
config_profiler();
9+
init::console();
10+
init::profiler();
1011
test::perform("FAST LOCK-FREE MPMC QUEUE TEST", test::config::mpmc {});
1112
return EXIT_SUCCESS;
1213
}

src/test_fast_mpsc_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Copyright (c) 2025 Vitaly Anasenko
22
// Distributed under the MIT License, see accompanying file LICENSE.txt
33

4+
#include "init.hpp"
45
#include "config.hpp"
56
#include "fast_queue_test.hpp"
67

78
int main(int, char **) {
8-
config_console();
9-
config_profiler();
9+
init::console();
10+
init::profiler();
1011
test::perform("FAST LOCK-FREE MPSC QUEUE TEST", test::config::mpsc {});
1112
return EXIT_SUCCESS;
1213
}

src/test_fastest_mpmc_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Copyright (c) 2025 Vitaly Anasenko
22
// Distributed under the MIT License, see accompanying file LICENSE.txt
33

4+
#include "init.hpp"
45
#include "config.hpp"
56
#include "fastest_queue_test.hpp"
67

78
int main(int, char **) {
8-
config_console();
9-
config_profiler();
9+
init::console();
10+
init::profiler();
1011
test::perform("FAST LOCK-FREE ALLOCATION-FREE MPMC QUEUE TEST", test::config::mpmc {});
1112
return EXIT_SUCCESS;
1213
}

src/test_fastest_mpsc_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Copyright (c) 2025 Vitaly Anasenko
22
// Distributed under the MIT License, see accompanying file LICENSE.txt
33

4+
#include "init.hpp"
45
#include "config.hpp"
56
#include "fastest_queue_test.hpp"
67

78
int main(int, char **) {
8-
config_console();
9-
config_profiler();
9+
init::console();
10+
init::profiler();
1011
test::perform("FAST LOCK-FREE ALLOCATION-FREE MPSC QUEUE TEST", test::config::mpsc {});
1112
return EXIT_SUCCESS;
1213
}

src/test_mpmc_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// Copyright (c) 2025 Vitaly Anasenko
22
// Distributed under the MIT License, see accompanying file LICENSE.txt
33

4+
#include "init.hpp"
45
#include "config.hpp"
56
#include "queue_test.hpp"
67
#include <xtxn/mpmc_queue.hpp>
78

89
int main(int, char **) {
9-
config_console();
10-
config_profiler();
10+
init::console();
11+
init::profiler();
1112
test::perform<xtxn::mpmc_queue<test::item_type>>(
1213
"CLASSIC MPMC QUEUE TEST (EPOCH-BASED RECLAMATION)",
1314
test::config::mpmc {}

src/test_mpmcdd_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// Copyright (c) 2025 Vitaly Anasenko
22
// Distributed under the MIT License, see accompanying file LICENSE.txt
33

4+
#include "init.hpp"
45
#include "config.hpp"
56
#include "queue_test.hpp"
67
#include <xtxn/mpmcdd_queue.hpp>
78

89
int main(int, char **) {
9-
config_console();
10-
config_profiler();
10+
init::console();
11+
init::profiler();
1112
test::perform<xtxn::mpmcdd_queue<test::item_type>>(
1213
"CLASSIC MPMC QUEUE TEST (DEFERRED DELETION)",
1314
test::config::mpmc {}

src/test_mpmcsl_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// Copyright (c) 2025 Vitaly Anasenko
22
// Distributed under the MIT License, see accompanying file LICENSE.txt
33

4+
#include "init.hpp"
45
#include "config.hpp"
56
#include "queue_test.hpp"
67
#include <xtxn/mpmcsl_queue.hpp>
78

89
int main(int, char **) {
9-
config_console();
10-
config_profiler();
10+
init::console();
11+
init::profiler();
1112
test::perform<xtxn::mpmcsl_queue<test::item_type>>(
1213
"CLASSIC MPMC QUEUE TEST (MPSC WITH SPINLOCK)",
1314
test::config::mpmc {}

src/test_mpsc_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// Copyright (c) 2025 Vitaly Anasenko
22
// Distributed under the MIT License, see accompanying file LICENSE.txt
33

4+
#include "init.hpp"
45
#include "config.hpp"
56
#include "queue_test.hpp"
67
#include <xtxn/mpsc_queue.hpp>
78

89
int main(int, char **) {
9-
config_console();
10-
config_profiler();
10+
init::console();
11+
init::profiler();
1112
test::perform<xtxn::mpsc_queue<test::item_type>>("CLASSIC MPSC QUEUE TEST", test::config::mpsc {});
1213
return EXIT_SUCCESS;
1314
}

0 commit comments

Comments
 (0)