mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
Merge pull request #178 from lemire/dlemire/adding_bloat_analysis
This adds bloat analysis to the tests.
This commit is contained in:
commit
a64cfc960b
@ -9,7 +9,7 @@ option(SYSTEM_DOCTEST "Use system copy of doctest" OFF)
|
|||||||
if (NOT SYSTEM_DOCTEST)
|
if (NOT SYSTEM_DOCTEST)
|
||||||
FetchContent_Declare(doctest
|
FetchContent_Declare(doctest
|
||||||
GIT_REPOSITORY https://github.com/onqtam/doctest.git
|
GIT_REPOSITORY https://github.com/onqtam/doctest.git
|
||||||
GIT_TAG v2.4.9)
|
GIT_TAG v2.4.10)
|
||||||
endif()
|
endif()
|
||||||
FetchContent_Declare(supplemental_test_files
|
FetchContent_Declare(supplemental_test_files
|
||||||
GIT_REPOSITORY https://github.com/fastfloat/supplemental_test_files.git
|
GIT_REPOSITORY https://github.com/fastfloat/supplemental_test_files.git
|
||||||
@ -83,3 +83,4 @@ if (FASTFLOAT_EXHAUSTIVE)
|
|||||||
endif(FASTFLOAT_EXHAUSTIVE)
|
endif(FASTFLOAT_EXHAUSTIVE)
|
||||||
|
|
||||||
add_subdirectory(build_tests)
|
add_subdirectory(build_tests)
|
||||||
|
add_subdirectory(bloat_analysis)
|
||||||
|
|||||||
5
tests/bloat_analysis/CMakeLists.txt
Normal file
5
tests/bloat_analysis/CMakeLists.txt
Normal 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)
|
||||||
9
tests/bloat_analysis/a1.cpp
Normal file
9
tests/bloat_analysis/a1.cpp
Normal 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;
|
||||||
|
}
|
||||||
9
tests/bloat_analysis/a10.cpp
Normal file
9
tests/bloat_analysis/a10.cpp
Normal 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;
|
||||||
|
}
|
||||||
9
tests/bloat_analysis/a2.cpp
Normal file
9
tests/bloat_analysis/a2.cpp
Normal 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;
|
||||||
|
}
|
||||||
9
tests/bloat_analysis/a3.cpp
Normal file
9
tests/bloat_analysis/a3.cpp
Normal 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;
|
||||||
|
}
|
||||||
9
tests/bloat_analysis/a4.cpp
Normal file
9
tests/bloat_analysis/a4.cpp
Normal 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;
|
||||||
|
}
|
||||||
9
tests/bloat_analysis/a5.cpp
Normal file
9
tests/bloat_analysis/a5.cpp
Normal 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;
|
||||||
|
}
|
||||||
9
tests/bloat_analysis/a6.cpp
Normal file
9
tests/bloat_analysis/a6.cpp
Normal 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;
|
||||||
|
}
|
||||||
9
tests/bloat_analysis/a7.cpp
Normal file
9
tests/bloat_analysis/a7.cpp
Normal 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;
|
||||||
|
}
|
||||||
9
tests/bloat_analysis/a8.cpp
Normal file
9
tests/bloat_analysis/a8.cpp
Normal 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;
|
||||||
|
}
|
||||||
9
tests/bloat_analysis/a9.cpp
Normal file
9
tests/bloat_analysis/a9.cpp
Normal 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;
|
||||||
|
}
|
||||||
19
tests/bloat_analysis/main.cpp
Normal file
19
tests/bloat_analysis/main.cpp
Normal 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);
|
||||||
|
}
|
||||||
13
tests/bloat_analysis/main_ref.cpp
Normal file
13
tests/bloat_analysis/main_ref.cpp
Normal 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);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user