Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_executable(bench_execution_gateway bench_execution_gateway.cpp)
add_executable(bench_feed_handler bench_feed_handler.cpp)
add_executable(bench_book_snapshot bench_book_snapshot.cpp)
add_executable(bench_position_manager bench_position_manager.cpp)
add_executable(bench_pipeline bench_pipeline.cpp)

# Link libraries for each
foreach(bench_target
Expand All @@ -19,7 +20,8 @@ foreach(bench_target
bench_execution_gateway
bench_feed_handler
bench_book_snapshot
bench_position_manager)
bench_position_manager
bench_pipeline)
target_link_libraries(${bench_target}
velox_core
benchmark::benchmark
Expand Down
54 changes: 54 additions & 0 deletions benchmarks/bench_pipeline.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <benchmark/benchmark.h>
#include "velox/core/symbol_engine.hpp"
#include "velox/risk/risk_manager.hpp"
#include "velox/gateway/execution_gateway.hpp"
#include "velox/risk/position_manager.hpp"
#include "velox/feed/feed_handler.hpp"
#include "lockfree/pool.hpp"

using namespace velox;

static void BM_Pipeline_ProcessFile(benchmark::State& state) {
for (auto _ : state) {
// Fresh components for each iteration
RiskManager risk;
ExecutionGateway gateway;
PositionManager pos_mgr;
FeedHandler feed;

// Add workers
for (int i = 0; i < 4; ++i) gateway.add_worker();

// Create engines for symbols that appear in the file
std::vector<std::unique_ptr<SymbolEngine>> engines;
engines.push_back(std::make_unique<SymbolEngine>("AAPL", &risk, &gateway, &pos_mgr));
engines.push_back(std::make_unique<SymbolEngine>("MSFT", &risk, &gateway, &pos_mgr));
engines.push_back(std::make_unique<SymbolEngine>("GOOGL", &risk, &gateway, &pos_mgr));

// Route orders from feed to correct engine
feed.on_add_order([&](const Order& order) {
for (auto& e : engines) {
if (strcmp(e->order_book().symbol(), order.symbol) == 0) {
static lockfree::ObjectPool<Order, 100000> pool;
static std::vector<lockfree::PooledPtr<Order, 100000>> pending;
auto new_order = pool.acquire();
*new_order = order;
e->on_market_order(new_order.get());
pending.push_back(std::move(new_order));
break;
}
}
});

// Process the mock file (or a larger test file)
feed.process_file("test_data/NASDAQ_ITCH50_sample.bin");

// Drain engines
for (auto& e : engines) e->run_match_cycle();

benchmark::DoNotOptimize(&gateway);
}
}
BENCHMARK(BM_Pipeline_ProcessFile);

BENCHMARK_MAIN();
4 changes: 3 additions & 1 deletion tests/test_integration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ class IntegrationTest : public ::testing::Test {
}

void submit_order(Order* order) {
/*
std::cout << "[INTEGRATION_TEST] Submitting order ID=" << order->order_id
<< " symbol=" << order->symbol << std::endl;

*/

// Find the correct engine for the symbol
for (auto& eng : engines) {
if (strcmp(eng->order_book().symbol(), order->symbol) == 0) {
Expand Down
Loading