Skip to content

Commit b79b98a

Browse files
author
Qi Chen
committed
fix linux localtime_s to localtime_r
1 parent 574412e commit b79b98a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Test/src/SPFreshTest.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,13 @@ void RunBenchmark(const std::string &vectorPath, const std::string &queryPath, c
572572
jsonFile << std::fixed << std::setprecision(4);
573573

574574
// Get current timestamp
575-
auto now = std::chrono::system_clock::now();
576-
auto time_t_now = std::chrono::system_clock::to_time_t(now);
575+
auto time_t_now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
577576
std::tm tm_now;
577+
#if defined(_MSC_VER)
578578
localtime_s(&tm_now, &time_t_now);
579+
#else
580+
localtime_r(&time_t_now, &tm_now);
581+
#endif
579582

580583
std::ostringstream timestampStream;
581584
timestampStream << std::put_time(&tm_now, "%Y-%m-%dT%H:%M:%S");
@@ -624,6 +627,11 @@ void RunBenchmark(const std::string &vectorPath, const std::string &queryPath, c
624627
BOOST_TEST_MESSAGE("\n=== Failed to create output.json ===");
625628
}
626629
}
630+
631+
M = oldM;
632+
K = oldK;
633+
N = oldN;
634+
queries = oldQueries;
627635
}
628636

629637
} // namespace SPFreshTest
@@ -1038,7 +1046,6 @@ BOOST_AUTO_TEST_CASE(IndexPersistenceAndInsertMultipleThreads)
10381046
// Cleanup
10391047
std::filesystem::remove_all("insert_test_index_multi");
10401048
std::filesystem::remove_all("insert_cloned_index_multi");
1041-
std::filesystem::remove_all("insert_final_index_multi");
10421049
}
10431050

10441051
BOOST_AUTO_TEST_CASE(IndexSaveDuringQuery)
@@ -1657,18 +1664,18 @@ BOOST_AUTO_TEST_CASE(BenchmarkFromConfig)
16571664
// Dispatch to appropriate type
16581665
if (valueType == VectorValueType::Float)
16591666
{
1660-
RunBenchmark<float>(vectorPath, queryPath, truthPath, distMethod, indexPath, dimension, baseVectorCount, insertVectorCount, 0,
1661-
batchNum, topK, numThreads, numQueries);
1667+
RunBenchmark<float>(vectorPath, queryPath, truthPath, distMethod, indexPath, dimension, baseVectorCount,
1668+
insertVectorCount, deleteVectorCount, batchNum, topK, numThreads, numQueries);
16621669
}
16631670
else if (valueType == VectorValueType::Int8)
16641671
{
16651672
RunBenchmark<std::int8_t>(vectorPath, queryPath, truthPath, distMethod, indexPath, dimension, baseVectorCount,
1666-
insertVectorCount, 0, batchNum, topK, numThreads, numQueries);
1673+
insertVectorCount, deleteVectorCount, batchNum, topK, numThreads, numQueries);
16671674
}
16681675
else if (valueType == VectorValueType::UInt8)
16691676
{
16701677
RunBenchmark<std::uint8_t>(vectorPath, queryPath, truthPath, distMethod, indexPath, dimension, baseVectorCount,
1671-
insertVectorCount, 0, batchNum, topK, numThreads, numQueries);
1678+
insertVectorCount, deleteVectorCount, batchNum, topK, numThreads, numQueries);
16721679
}
16731680

16741681
std::filesystem::remove_all(indexPath);

0 commit comments

Comments
 (0)