fixes and refactorings
This commit is contained in:
parent
9e5b79cb34
commit
ead9c0ee2e
7 changed files with 30 additions and 23 deletions
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -11,7 +11,7 @@
|
|||
"program": "${workspaceFolder}/build/mana_auto_replay",
|
||||
"args": [
|
||||
"~/Documents/is690-9Li_3H_run094_241020_124254_part001.zip",
|
||||
"--plugin=src/libmana-plugin-c-test.so"
|
||||
"--plugin=src/libmana-plugin-root-histogram.so"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}/build",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef C536E080_25D7_476D_B8E3_25912B9CFC3B
|
||||
#define C536E080_25D7_476D_B8E3_25912B9CFC3B
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
|
@ -21,6 +22,6 @@ inline double make_quiet_nan()
|
|||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mesytec::mnode
|
||||
|
||||
#endif /* C536E080_25D7_476D_B8E3_25912B9CFC3B */
|
||||
|
|
|
@ -17,7 +17,7 @@ if (MNODE_BUILD_TESTS)
|
|||
function (add_mnode_gtest name)
|
||||
add_executable(test_${name} ${name}.test.cc)
|
||||
target_link_libraries(test_${name} PRIVATE mesytec-mnode GTest::gtest_main spdlog)
|
||||
add_test(NAME name COMMAND $<TARGET_FILE:test_${name}>)
|
||||
add_test(NAME test_${name} COMMAND $<TARGET_FILE:test_${name}>)
|
||||
endfunction()
|
||||
|
||||
add_mnode_gtest(mana)
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <list>
|
||||
#include <mesytec-mnode/mnode_cpp_types.h>
|
||||
#include <mesytec-mnode/mnode_math.h>
|
||||
#include <mesytec-mvlc/util/fmt.h>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
namespace mesytec::mnode::mana
|
||||
{
|
||||
|
@ -15,7 +17,7 @@ class Arena
|
|||
{
|
||||
public:
|
||||
static constexpr size_t initial_segment_size = 1u << 20;
|
||||
static constexpr size_t default_pad = 8;
|
||||
static constexpr size_t default_align_to = 8;
|
||||
static constexpr size_t default_max_segments = 1;
|
||||
|
||||
Arena() = default;
|
||||
|
@ -25,11 +27,11 @@ class Arena
|
|||
Arena &operator=(Arena &&other) = default;
|
||||
|
||||
// pushes at least the required amount of memory onto the arena.
|
||||
// 'required' is rounded up to the nearest multiple of 'default_pad' to make
|
||||
// 'required' is rounded up to the nearest multiple of 'default_align_to' to make
|
||||
// subsequent allocations aligned.
|
||||
u8 *push_size(size_t required)
|
||||
{
|
||||
size_t padded = round_up(required, default_pad);
|
||||
size_t padded = round_up(required, default_align_to);
|
||||
size_t pad_waste = padded - required;
|
||||
required = padded;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "internal/mana_arena.h"
|
||||
#include "internal/mana_lib.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
#include <mesytec-mnode/mnode_cpp_types.h>
|
||||
#include "internal/mana_arena.h"
|
||||
#include <spdlog/spdlog.h>
|
||||
#include "internal/mana_lib.hpp"
|
||||
|
||||
using namespace mesytec::mnode;
|
||||
|
||||
|
@ -18,35 +18,35 @@ TEST(mnode_mana_arena, push_reset_push)
|
|||
|
||||
for (size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
auto mem = arena.push_size(mana::Arena::default_pad + 2);
|
||||
auto mem = arena.push_size(mana::Arena::default_align_to + 2);
|
||||
ASSERT_NE(mem, nullptr);
|
||||
}
|
||||
|
||||
ASSERT_EQ(arena.allocations(), 10);
|
||||
ASSERT_GE(arena.pad_waste(), 0);
|
||||
ASSERT_GE(arena.segment_count(), 1);
|
||||
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_pad + 2));
|
||||
ASSERT_EQ(arena.used(), 10 * (mana::Arena::default_pad + 2));
|
||||
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_align_to + 2));
|
||||
ASSERT_EQ(arena.used(), 10 * (mana::Arena::default_align_to + 2));
|
||||
|
||||
arena.reset();
|
||||
|
||||
ASSERT_EQ(arena.allocations(), 0);
|
||||
ASSERT_EQ(arena.pad_waste(), 0);
|
||||
ASSERT_GE(arena.segment_count(), 1);
|
||||
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_pad + 2));
|
||||
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_align_to + 2));
|
||||
ASSERT_EQ(arena.used(), 0);
|
||||
|
||||
for (size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
auto mem = arena.push_size(mana::Arena::default_pad + 2);
|
||||
auto mem = arena.push_size(mana::Arena::default_align_to + 2);
|
||||
ASSERT_NE(mem, nullptr);
|
||||
}
|
||||
|
||||
ASSERT_EQ(arena.allocations(), 10);
|
||||
ASSERT_GE(arena.pad_waste(), 0);
|
||||
ASSERT_GE(arena.segment_count(), 1);
|
||||
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_pad + 2));
|
||||
ASSERT_EQ(arena.used(), 10 * (mana::Arena::default_pad + 2));
|
||||
ASSERT_GE(arena.capacity(), 10 * (mana::Arena::default_align_to + 2));
|
||||
ASSERT_EQ(arena.used(), 10 * (mana::Arena::default_align_to + 2));
|
||||
}
|
||||
|
||||
TEST(mnode_mana_offset_ptr, basic)
|
||||
|
@ -93,8 +93,8 @@ TEST(mnode_mana_offset_ptr, strings)
|
|||
auto s0 = arena.push_cstr("hello");
|
||||
auto s1 = arena.push_cstr("world");
|
||||
|
||||
spdlog::info("&t->ptr0={}, &t->ptr1={}", fmt::ptr(&t->ptr0), fmt::ptr(&t->ptr1));
|
||||
spdlog::info("s0={} @ {}, s1={} @ {}", s0, fmt::ptr(s0), s1, fmt::ptr(s1));
|
||||
// spdlog::info("&t->ptr0={}, &t->ptr1={}", fmt::ptr(&t->ptr0), fmt::ptr(&t->ptr1));
|
||||
// spdlog::info("s0={} @ {}, s1={} @ {}", s0, fmt::ptr(s0), s1, fmt::ptr(s1));
|
||||
|
||||
set(t->ptr0, s0);
|
||||
set(t->ptr1, s1);
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace py = pybind11;
|
|||
|
||||
PYBIND11_EMBEDDED_MODULE(py_mana, m) {}
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Context
|
||||
{
|
||||
py::scoped_interpreter interp;
|
||||
|
@ -23,6 +25,7 @@ struct Context
|
|||
py::object py_end_run;
|
||||
std::vector<std::vector<py::object>> eventBuffers;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
MANA_DEFINE_PLUGIN_INIT(init)
|
||||
{
|
||||
|
|
|
@ -295,8 +295,9 @@ struct NngPairStrategy: public ProcessingStrategy
|
|||
auto s = sw.get_elapsed().count() / (1000.0 * 1000.0);
|
||||
auto bytesPerSecond = totalBytesProcessed / s;
|
||||
auto MiBPerSecond = bytesPerSecond / (1u << 20);
|
||||
std::cout << fmt::format("Processed {} buffers, {} bytes. t={} s, rate={} MiB/s\n",
|
||||
bufferNumber, totalBytesProcessed, s, MiBPerSecond);
|
||||
std::cout << fmt::format(
|
||||
"Processed {} buffers, {} bytes. t={} s, rate={:.2f} MiB/s\n", bufferNumber,
|
||||
totalBytesProcessed, s, MiBPerSecond);
|
||||
}(sw, bufferNumber, totalBytesProcessed);
|
||||
};
|
||||
|
||||
|
@ -343,9 +344,9 @@ struct NngPairStrategy: public ProcessingStrategy
|
|||
}
|
||||
|
||||
report();
|
||||
spdlog::info("NngPairStrategy: producerTx: {} MiB, {} messages",
|
||||
spdlog::debug("NngPairStrategy: producerTx: {:.2f} MiB, {} messages",
|
||||
producerTx.bytes / (1024.0 * 1024), producerTx.messages);
|
||||
spdlog::info("NngPairStrategy: consumerRx: {} MiB, {} messages",
|
||||
spdlog::debug("NngPairStrategy: consumerRx: {:.2f} MiB, {} messages",
|
||||
consumerRx.bytes / (1024.0 * 1024), consumerRx.messages);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue