mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
some include fixes
This commit is contained in:
parent
22b4f3becf
commit
668d22f39f
3 changed files with 14 additions and 7 deletions
|
@ -17,12 +17,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "benchmark_setup.h"
|
#include "catch.h"
|
||||||
#include "threading/ipc_channel.h"
|
#include "threading/ipc_channel.h"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
TEST_CASE("benchmark_ipc_channel")
|
TEST_CASE("benchmark_ipc_channel")
|
||||||
{
|
{
|
||||||
// same as in test_threading.cpp (TODO: remove duplication)
|
// same as in test_threading.cpp (TODO: remove duplication)
|
||||||
|
@ -80,13 +78,23 @@ TEST_CASE("benchmark_ipc_channel")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
BENCHMARK("simple_call", i) {
|
BENCHMARK("simple_call_1", i) {
|
||||||
char buf[16] = {};
|
char buf[16] = {};
|
||||||
buf[i & 0xf] = i;
|
buf[i & 0xf] = i;
|
||||||
end_a.exchange(buf, 16);
|
end_a.exchange(buf, 16);
|
||||||
return reinterpret_cast<const u8 *>(end_a.getRecvData())[i & 0xf];
|
return reinterpret_cast<const u8 *>(end_a.getRecvData())[i & 0xf];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BENCHMARK("simple_call_1000", i) {
|
||||||
|
char buf[16] = {};
|
||||||
|
buf[i & 0xf] = i;
|
||||||
|
for (int k = 0; k < 1000; ++k) {
|
||||||
|
buf[0] = k & 0xff;
|
||||||
|
end_a.exchange(buf, 16);
|
||||||
|
}
|
||||||
|
return reinterpret_cast<const u8 *>(end_a.getRecvData())[i & 0xf];
|
||||||
|
};
|
||||||
|
|
||||||
// stop thread_b
|
// stop thread_b
|
||||||
end_a.exchange(nullptr, 0);
|
end_a.exchange(nullptr, 0);
|
||||||
REQUIRE(end_a.getRecvSize() == 0);
|
REQUIRE(end_a.getRecvSize() == 0);
|
||||||
|
|
|
@ -24,10 +24,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#if defined(IPC_CHANNEL_IMPLEMENTATION_LINUX_FUTEX)
|
#if defined(IPC_CHANNEL_IMPLEMENTATION_LINUX_FUTEX)
|
||||||
#include <linux/futex.h>
|
#include <linux/futex.h>
|
||||||
#include <cstring>
|
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
|
|
@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define IPC_CHANNEL_IMPLEMENTATION_WIN32
|
#define IPC_CHANNEL_IMPLEMENTATION_WIN32
|
||||||
|
@ -37,8 +38,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
#if defined(IPC_CHANNEL_IMPLEMENTATION_WIN32)
|
#if defined(IPC_CHANNEL_IMPLEMENTATION_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#elif defined(IPC_CHANNEL_IMPLEMENTATION_LINUX_FUTEX)
|
|
||||||
#include <atomic>
|
|
||||||
#elif defined(IPC_CHANNEL_IMPLEMENTATION_POSIX)
|
#elif defined(IPC_CHANNEL_IMPLEMENTATION_POSIX)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue