This commit is contained in:
Zengtudor 2024-08-16 14:02:03 +08:00
parent e13bcbb5f4
commit 5215cdc0ad
4 changed files with 11 additions and 7 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
# ---> C++ # ---> C++
/tests
/build /build
/.xmake /.xmake
/.vscode /.vscode

View File

@ -19,7 +19,7 @@
#include "unistd.h" #include "unistd.h"
#endif #endif
using std::cerr,std::endl,std::cout,std::ifstream,std::string,std::vector,std::queue,std::filesystem::path,std::thread,std::chrono::time_point,std::chrono::steady_clock,std::chrono::high_resolution_clock; using std::cerr,std::endl,std::cout,std::ifstream,std::string,std::vector,std::queue,std::filesystem::path,std::thread,std::chrono::time_point,std::chrono::steady_clock,std::chrono::high_resolution_clock,std::chrono::system_clock,std::filesystem::exists;
#define AS_EQ(a,b){if((a)!=(b)){cerr<<"assert eq failed :"<<endl<<#a<<":"<<(a)<<endl<<#b<<":"<<(b)<<endl;exit(1);}} #define AS_EQ(a,b){if((a)!=(b)){cerr<<"assert eq failed :"<<endl<<#a<<":"<<(a)<<endl<<#b<<":"<<(b)<<endl;exit(1);}}
#define AS_NE(a,b){if((a)==(b)){cerr<<"assert not eq failed :"<<endl<<#a<<":"<<(a)<<endl<<#b<<":"<<(b)<<endl;exit(1);}} #define AS_NE(a,b){if((a)==(b)){cerr<<"assert not eq failed :"<<endl<<#a<<":"<<(a)<<endl<<#b<<":"<<(b)<<endl;exit(1);}}
@ -40,9 +40,9 @@ using std::cerr,std::endl,std::cout,std::ifstream,std::string,std::vector,std::q
GetSystemInfo( &sysInfo ); GetSystemInfo( &sysInfo );
return sysInfo.dwNumberOfProcessors; return sysInfo.dwNumberOfProcessors;
} }
#elif #else
unsigned long getCpuNums(){ unsigned long getCpuNums(){
return sysconf(_SC_NPROCESSORS_ONLN) return sysconf(_SC_NPROCESSORS_ONLN);
} }
#endif #endif
@ -60,8 +60,8 @@ struct Test{
}; };
struct ProgramRet{ struct ProgramRet{
time_point<steady_clock> start; time_point<system_clock> start;
time_point<steady_clock> end; time_point<system_clock> end;
}; };
template<typename T> template<typename T>
@ -135,6 +135,10 @@ int main(int argc, char* argv[]) {
} }
queue<std::function<ProgramRet()>> tasks; queue<std::function<ProgramRet()>> tasks;
const auto testsPath = projectPath/"tests"; const auto testsPath = projectPath/"tests";
if(!exists(testsPath)){
LOG("creating the test dir")
std::filesystem::create_directory(testsPath);
}
printValue(testsPath) printValue(testsPath)
const string exePathStr = getProtectPath(exePath); const string exePathStr = getProtectPath(exePath);
for(auto i:tests){ for(auto i:tests){

View File

@ -1 +0,0 @@
1

View File

@ -7,7 +7,7 @@
], ],
"tests":[ "tests":[
{ {
"in":"1.in", "in":"a.in",
"ans":"1.ans" "ans":"1.ans"
} }
] ]