Browse Source

feat: add _tmain test interface

legacy
Dnomd343 2 years ago
parent
commit
031224a859
  1. 2
      src/klotski/CMakeLists.txt
  2. 10
      src/klotski/ffi/klotski.h
  3. 8
      src/klotski/ffi/klotski_ffi.cc
  4. 19
      src/klotski/ffi/tmain.cc
  5. 16
      src/main.cc

2
src/klotski/CMakeLists.txt

@ -29,7 +29,7 @@ add_subdirectory(fast_cal)
################################################
#add_library(klotski STATIC klotski_ffi.cc)
add_library(klotski SHARED ffi/klotski_ffi.cc)
add_library(klotski SHARED ffi/klotski_ffi.cc ffi/tmain.cc)
################################################

10
src/klotski/ffi/klotski.h

@ -1,4 +1,12 @@
#pragma once
extern "C" {
void _tmain();
}
extern "C" {
void short_code_speed_up();
void short_code_speed_up_fast();
void short_code_speed_up_normal();
}

8
src/klotski/ffi/klotski_ffi.cc

@ -2,10 +2,10 @@
#include "short_code.h"
void short_code_speed_up_fast() {
ShortCode::speed_up(ShortCode::FAST);
void short_code_speed_up() {
ShortCode::speed_up(ShortCode::NORMAL);
}
void short_code_speed_up_normal() {
ShortCode::speed_up(ShortCode::NORMAL);
void short_code_speed_up_fast() {
ShortCode::speed_up(ShortCode::FAST);
}

19
src/klotski/ffi/tmain.cc

@ -0,0 +1,19 @@
#include <iostream>
#include "klotski.h"
#include "core.h"
void _tmain() {
// std::cout << "test" << std::endl;
uint64_t raw_code = 0x0603EDF5CAFFF5E2;
auto core = Core([](uint64_t code, uint64_t mask) {
return;
});
for (uint32_t i = 0; i < 1000000; ++i) {
core.next_cases(raw_code, 0);
}
}

16
src/main.cc

@ -1,5 +1,7 @@
#include <iostream>
#include "ffi/klotski.h"
//#include "utils/common.h"
//#include "all_cases/all_cases.h"
//
@ -13,13 +15,13 @@
//#include "graph.h"
#include "benchmark.h"
//#include "benchmark.h"
//#include <unistd.h>
int main() {
std::cout << "start test" << std::endl;
// std::cout << "start test" << std::endl;
// std::cout << (uint32_t)Common::check_range(1, Common::range_reverse(0xA9BF0C00)) << std::endl;
//
@ -54,9 +56,15 @@ int main() {
// std::cout << s << std::endl;
// }
Benchmark::basic_ranges(std::cout);
// Benchmark::basic_ranges(std::cout);
auto start = clock();
_tmain();
std::cerr << (clock() - start) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
std::cout << "end test" << std::endl;
// std::cout << "end test" << std::endl;
// BasicRanges::build();

Loading…
Cancel
Save