Merge pull request #178 from lemire/dlemire/adding_bloat_analysis

This adds bloat analysis to the tests.
This commit is contained in:
Daniel Lemire 2023-02-28 17:19:25 -05:00 committed by GitHub
commit a64cfc960b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 129 additions and 1 deletions

View File

@ -9,7 +9,7 @@ option(SYSTEM_DOCTEST "Use system copy of doctest" OFF)
if (NOT SYSTEM_DOCTEST)
FetchContent_Declare(doctest
GIT_REPOSITORY https://github.com/onqtam/doctest.git
GIT_TAG v2.4.9)
GIT_TAG v2.4.10)
endif()
FetchContent_Declare(supplemental_test_files
GIT_REPOSITORY https://github.com/fastfloat/supplemental_test_files.git
@ -83,3 +83,4 @@ if (FASTFLOAT_EXHAUSTIVE)
endif(FASTFLOAT_EXHAUSTIVE)
add_subdirectory(build_tests)
add_subdirectory(bloat_analysis)

View File

@ -0,0 +1,5 @@
add_executable(bloaty main.cpp a1.cpp a2.cpp a3.cpp a4.cpp a4.cpp a5.cpp a6.cpp a7.cpp a8.cpp a9.cpp a10.cpp)
target_link_libraries(bloaty PUBLIC fast_float)
add_executable(bloatyref main_ref.cpp)
target_link_libraries(bloatyref PUBLIC fast_float)

View File

@ -0,0 +1,9 @@
#include "fast_float/fast_float.h"
double get1(const char* input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 1; }
return result_value;
}

View File

@ -0,0 +1,9 @@
#include "fast_float/fast_float.h"
double get10(const char* input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 10; }
return result_value;
}

View File

@ -0,0 +1,9 @@
#include "fast_float/fast_float.h"
double get2(const char* input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 2; }
return result_value;
}

View File

@ -0,0 +1,9 @@
#include "fast_float/fast_float.h"
double get3(const char* input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 3; }
return result_value;
}

View File

@ -0,0 +1,9 @@
#include "fast_float/fast_float.h"
double get4(const char* input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 4; }
return result_value;
}

View File

@ -0,0 +1,9 @@
#include "fast_float/fast_float.h"
double get5(const char* input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 5; }
return result_value;
}

View File

@ -0,0 +1,9 @@
#include "fast_float/fast_float.h"
double get6(const char* input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 6; }
return result_value;
}

View File

@ -0,0 +1,9 @@
#include "fast_float/fast_float.h"
double get7(const char* input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 7; }
return result_value;
}

View File

@ -0,0 +1,9 @@
#include "fast_float/fast_float.h"
double get8(const char* input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 8; }
return result_value;
}

View File

@ -0,0 +1,9 @@
#include "fast_float/fast_float.h"
double get9(const char* input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 9; }
return result_value;
}

View File

@ -0,0 +1,19 @@
double get1(const char* input);
double get2(const char* input);
double get3(const char* input);
double get4(const char* input);
double get5(const char* input);
double get6(const char* input);
double get7(const char* input);
double get8(const char* input);
double get9(const char* input);
double get10(const char* input);
int main(int arg, char** argv) {
double x = get1(argv[0]) + get2(argv[0]) + get3(argv[0]) + get4(argv[0]) + get5(argv[0])
+ get6(argv[0]) + get7(argv[0]) + get8(argv[0]) + get9(argv[0]) + get10(argv[0]);
return int(x);
}

View File

@ -0,0 +1,13 @@
#include "fast_float/fast_float.h"
double get(const char * input) {
double result_value;
auto result = fast_float::from_chars(input, input + strlen(input), result_value);
if (result.ec != std::errc()) { return 10; }
return result_value;
}
int main(int arg, char** argv) {
double x = get(argv[0]);
return int(x);
}