Skip to content

Commit

Permalink
Added nanobench segments in text prediction
Browse files Browse the repository at this point in the history
  • Loading branch information
FuexFollets committed Feb 8, 2024
1 parent a14fdf1 commit 36a261b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions tests/vector_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <string>
#include <vector>

#include <nanobench.h>

#include <lexocraft/fancy_eigen_print.hpp>
#include <lexocraft/llm/vector_database.hpp>

Expand All @@ -24,7 +26,7 @@ int main(int argc, char** argv) {
if (args.at(0) == "create") {
const std::string path_from = args.at(1);
const std::string path_to = args.at(2);
const int total_trees = (args.size() > 4) ? std::stoi(args.at(3)) : 50;
const int total_trees = (args.size() > 3) ? std::stoi(args.at(3)) : 10;

std::ifstream file {path_from};
std::vector<lc::WordVector> words;
Expand All @@ -41,7 +43,9 @@ int main(int argc, char** argv) {
lc::VectorDatabase database {words};

std::cout << "Building Annoy index\n";
database.build_annoy_index(total_trees);
ankerl::nanobench::Bench().run("build_annoy_index", [&] {
ankerl::nanobench::doNotOptimizeAway(database.build_annoy_index(total_trees));
});
std::cout << "Annoy index built\n";

database.save_file(path_to);
Expand Down
5 changes: 4 additions & 1 deletion tests/vector_database_synonyms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ int main(int argc, char** argv) {
database = lc::VectorDatabase {words};

std::cout << "Building Annoy index\n";
database.build_annoy_index(2);
ankerl::nanobench::Bench().run("build_annoy_index", [&] {
database.build_annoy_index(10);
});

std::cout << "Annoy index built\n";
}

Expand Down

0 comments on commit 36a261b

Please sign in to comment.