diff --git a/README.md b/README.md index c8ad6a1f7..946a12fc3 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.4.38.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.4.39.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.4.38_amd64.deb`. +| `package` | Generate debian package `meevax_0.4.39_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -120,7 +120,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.4.38 +Meevax Lisp System, version 0.4.39 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index b58b5bc5c..05c945a8f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.38 +0.4.39 diff --git a/include/meevax/kernel/heterogeneous.hpp b/include/meevax/kernel/heterogeneous.hpp index 91c31f6b1..2515e8187 100644 --- a/include/meevax/kernel/heterogeneous.hpp +++ b/include/meevax/kernel/heterogeneous.hpp @@ -81,10 +81,11 @@ inline namespace kernel template static auto allocate(Us&&... xs) { - #if PROFILE_ALLOCATION - current_profiler().by_type[typeid(typename std::decay::type)].allocation++; - current_profiler().by_type[typeid(void)].allocation++; - #endif + if constexpr (profiler::count_allocations) + { + current_profiler().allocation_counts[typeid(Bound)]++; + current_profiler().allocation_counts[typeid(void)]++; + } if constexpr (std::is_same_v) { diff --git a/include/meevax/kernel/overview.hpp b/include/meevax/kernel/overview.hpp index 76b2a6e99..3d3ad6c3c 100644 --- a/include/meevax/kernel/overview.hpp +++ b/include/meevax/kernel/overview.hpp @@ -24,8 +24,6 @@ #define NIL /* nothing */ -#define PROFILE_ALLOCATION true - namespace meevax { inline namespace kernel diff --git a/include/meevax/kernel/profiler.hpp b/include/meevax/kernel/profiler.hpp index 58ac9fed2..e03e6a71f 100644 --- a/include/meevax/kernel/profiler.hpp +++ b/include/meevax/kernel/profiler.hpp @@ -26,12 +26,9 @@ inline namespace kernel { struct profiler { - struct topic - { - std::size_t allocation = 0; - }; + static constexpr auto count_allocations = false; - std::unordered_map by_type; + std::unordered_map allocation_counts; ~profiler(); }; diff --git a/src/kernel/profiler.cpp b/src/kernel/profiler.cpp index 56db3166a..0d53fda6d 100644 --- a/src/kernel/profiler.cpp +++ b/src/kernel/profiler.cpp @@ -14,7 +14,7 @@ limitations under the License. */ -#include +#include #include #include @@ -37,17 +37,21 @@ inline namespace kernel profiler::~profiler() { - if (auto file = std::ofstream("/tmp/meevax-profile-by-type.txt"); file) + if (auto ss = std::stringstream(); not std::empty(allocation_counts)) { - for (auto&& [type, topic] : by_type) + for (auto&& [type, value] : allocation_counts) { - file << topic.allocation << "\t" << demangle(type.name()) << "\n"; + ss << demangle(type.name()) << "\t" << value << "\n"; } - } - sh("cat /tmp/meevax-profile-by-type.txt | sed 's/meevax::kernel:://g' \ - | sort -rn \ - | column -t -s'\t'"); + sh("echo \"" + ss.str() + "\" | sed 's/meevax::kernel:://g' \ + | sort --field-separator='\t' \ + --key=2 \ + --numeric-sort \ + --reverse \ + | echo \"TYPENAME\tALLOCATION COUNT\n$(cat -)\" \ + | column -t -s'\t'"); + } } auto current_profiler() -> profiler &