Files
CPP/ctest/main.cpp
2025-08-10 11:37:45 -04:00

173 lines
4.2 KiB
C++

#include <stdio.h>
#include <common/string.hpp>
#include <common/block.hpp>
#include <common/pointer.hpp>
#include <common/fileio.hpp>
#include <common/profiler.hpp>
#include <common/mmap.hpp>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <tuple>
#include <complex>
// #include <iostream> // For standard input/output operations (like std::cout)
// #include <fstream> // For file stream operations (like std::ifstream)
// #include <string> // For using std::string
// int main()
// {
// Profiler profiler = Profiler();
// std::ifstream inputFile("/mnt/mariadb/backupdb.sql");
// if (!inputFile.is_open())
// {
// std::cerr << "Error: Could not open the file." << std::endl;
// return 1; // Indicate an error
// }
// DWORD lines = 0;
// std::string line;
// while (std::getline(inputFile, line))
// {
// lines++;
// if(!(lines%1000000))
// {
// std::cout << "reading " << lines << " " << line << std::endl;
// }
// }
// inputFile.close();
// std::cout << "Done, total took " << profiler.end() << " (ms)" << std::endl;
// return 0; // Indicate successful execution
// }
// int main(int argc, char ** argv)
// {
// Profiler profiler = Profiler();
// FileIO inputFile = FileIO("/mnt/mariadb/backupdb.sql");
// inputFile.setBufferLength(500000000);
// // FileIO inputFile = FileIO("/home/pi/Boneyard/ctest/main.cpp");
// String strLine = String();
// DWORD length = 0;
// DWORD lines = 0;
// printf("opening...\n");
// while(inputFile.readLine(strLine))
// {
// lines++;
// // printf("reading %d %s\n",lines,(char*)strLine);
// if(!(lines%1000000))
// {
// printf("reading %d %s\n",lines,(char*)strLine);
// }
// }
// printf("Done, read %d lines\n",lines);
// inputFile.close();
// printf("done, took %d(ms)...\n",profiler.end());
// return 0;
// }
std::tuple<int,int,int> foo()
{
return std::make_tuple(2,3,4);
}
int main(int argc, char ** argv)
{
// std::complex<double> c{4.0,3.0};
// FileIO fileIO = FileIO("/mnt/mariadb/backupdb.sql");
// std::cout << "Reading ... " << std::endl;
// int lines =0;
// String strLine;
// while(fileIO.readLine(strLine))
// {
// lines++;
// if(!(lines%1000000))
// {
// printf("reading %d %s\n",lines,(char*)strLine);
// }
// }
// fileIO.close();
}
void stdLibStuff()
{
// std::vector<int> numbers;
// numbers.push_back(100);
// numbers.push_back(50);
// numbers.push_back(100);
// int *p=&numbers[0];
// int *p1=&numbers[1];
// int *p2=&numbers[2];
// int max = *std::max_element(numbers.begin(), numbers.end());
// std::cout << typeid(max_it).name() << std::endl;
// if(max_it == p)std::cout << "p" << std::endl;
// if(max_it == p1) std::cout << "p1" << std::endl;
// if(max_it == p2)std::cout << "p2" << std::endl;
// std::cout << *max_it << std::endl;
// int max_value = *max_it;
// std::max(*numbers.begin());
// std::cout << std::max(numbers) << std::endl;
// Block<int> numbers;
// numbers.insert(newInt(100);
// std::cout<< std::min(100,50) << std::endl;
// std::string s = "hello";
// std::cout << s << std::endl;
// std::vector<std::string> strings;
// strings.push_back("hello");
// strings.push_back("world");
// for (const std::string& s : strings)
// {
// std::cout << s << " ";
// }
// char buffer[] = "Another direct copy";
// int a = sizeof(buffer);
}
void readFile()
{
// MemoryMappedFile memoryMappedFile("/home/pi/Boneyard/ctest/main.cpp",MemoryMappedFile::CreationFlags::ReadOnly);
// MemoryMappedFile memoryMappedFile("/home/pi/Boneyard/ctest/test.txt",MemoryMappedFile::CreationFlags::ReadOnly);
MemoryMappedFile memoryMappedFile("/mnt/mariadb/backupdb.sql",MemoryMappedFile::CreationFlags::ReadOnly);
Profiler profiler = Profiler();
String strLine;
DWORD lines = 0;
strLine.reserve(1400000,0);
while(memoryMappedFile.readLine(strLine))
{
// printf("%s\n",(char*)strLine);
lines++;
if(!(lines%1000000))
{
printf("reading %d %s\n",lines,(char*)strLine);
}
}
memoryMappedFile.close();
printf("done, took %d(ms)...\n",profiler.end());
}