raw pointers replaced with smart pointers

This commit is contained in:
apostolos
2021-09-15 13:03:25 +03:00
committed by Konstantinos Margaritis
parent d9b8e9e224
commit 390573a07a
4 changed files with 33 additions and 35 deletions

View File

@@ -5,6 +5,7 @@
#include <time.h>
#include <functional>
#include <vector>
#include <memory>
#define MAX_LOOPS 500000000
#define MAX_MATCHES 10
@@ -14,7 +15,7 @@ int main(){
int sizes[] = { 16000, 32000, 64000, 120000, 1600000, 2000000, 2500000, 3500000, 150000000, 250000000, 350000000, 500000000 };
const char charset[] = "aAaAaAaAAAaaaaAAAAaaaaAAAAAAaaaAAaaa";
for (size_t i = 0; i < std::size(sizes); i++) {
for(int j = 0; j < 4; j++) {
for(size_t j = 0; j < std::size(functions); j++) {
functions[j](sizes[i], MAX_LOOPS / sizes[i], MAX_MATCHES, false);
functions[j](sizes[i], MAX_LOOPS / sizes[i], MAX_MATCHES, true);
}
@@ -22,15 +23,14 @@ int main(){
for(size_t i=0; i < std::size(sizes); i++){
//we imitate the noodle unit tests
for (int char_len = 1; char_len < 9; char_len++) {
char *str = new char[char_len];
std::unique_ptr<char []> str ( new char[char_len] );
for (int j=0; j<char_len; j++) {
srand (time(NULL));
int key = rand() % + 36 ;
str[char_len] = charset[key];
str[char_len + 1] = '\0';
}
noodle_benchmarks(sizes[i], MAX_LOOPS / sizes[i], str,char_len, 0);
delete [] str;
noodle_benchmarks(sizes[i], MAX_LOOPS / sizes[i], str.get(), char_len, 0);
}
}
return 0;