diff --git a/Changes.md b/Changes.md index 765e56fd..64b5fc29 100644 --- a/Changes.md +++ b/Changes.md @@ -2,6 +2,7 @@ libhxcpp 6.0.0 (unreleased) ------------------------------------------------------------ +* Added HXCPP_PROGRESS_PERCENT, which shows a group's compile progress as a percentage of its files, [42.5% ], instead of a count, [425/1000] * Fixed a program on Linux with glibc staying as large as its largest burst of large allocations, such as the files a game reads while it loads: glibc keeps a freed buffer's memory in its heap unless it had mapped the buffer on its own, and once a buffer mapped on its own has been freed it stops mapping those of that size or less, up to 32 MB. The memory of the large buffers a collection freed then stayed the process's. The collector now trims the C heap once 16 MB has been freed to it, on the thread that frees the buffers. A program that dropped 384 MB of 4 MB buffers stayed at 396 MB resident and now returns to 12 MB * Fixed a native extension that includes hx/CFFI.h before hx/CFFIPrime.h, as SteamWrap does, failing to compile with hxs_encoding, hxs_utf16 and alloc_hxs_utf8 not declared: CFFI.h included first declares the CFFI API without HXCPP_PRIME, so without the Prime string functions that the ordinary wrapper of a DEFINE_PRIME function now uses. CFFIPrime.h declares them then * Made the collector's thread context on Linux a __thread pointer, read with one load from the thread pointer, instead of a call to pthread_getspecific each time an allocation leaves the inline path or a String or number is boxed. It was 3 to 4% of an OpenFL game's main thread. HXCPP_PTHREAD_FAST_TLS keeps pthread_getspecific (libhxcpp #429) diff --git a/docs/build_xml/Defines.md b/docs/build_xml/Defines.md index 67fbe6f2..d31903c2 100755 --- a/docs/build_xml/Defines.md +++ b/docs/build_xml/Defines.md @@ -81,6 +81,7 @@ Other defines: | *HXCPP_QUIET* | Print less output from the build tool | | *HXCPP_SILENT* | Print only errors from the build tool | | *HXCPP_COMPILE_THREADS* | Number of files to compile at once (also read from the environment) | +| *HXCPP_PROGRESS_PERCENT* | Show a group's progress as a percentage of its files, instead of a count | | *HXCPP_COMPILE_CACHE* | Directory for the compile cache, usually set in the environment. See [CompileCache.md](../CompileCache.md) | | *HXCPP_TIMES* | Show some basic profiling information | | *HXCPP_NEKO_BUILDTOOL* | Force use of hxcpp.n, rather than compiled BuildTool.exe diff --git a/tools/hxcpp/BuildTool.hx b/tools/hxcpp/BuildTool.hx index 3bda4d3d..7fa8dc4d 100644 --- a/tools/hxcpp/BuildTool.hx +++ b/tools/hxcpp/BuildTool.hx @@ -688,7 +688,7 @@ class BuildTool } : null; Profile.push("compile"); - var progress = new Progress(to_be_compiled.length); + var progress = new Progress(to_be_compiled.length, mDefines.exists("HXCPP_PROGRESS_PERCENT")); if (threadPool==null) { for(file in to_be_compiled) diff --git a/tools/hxcpp/Progress.hx b/tools/hxcpp/Progress.hx index 0bbc560d..335c2a87 100644 --- a/tools/hxcpp/Progress.hx +++ b/tools/hxcpp/Progress.hx @@ -1,17 +1,29 @@ -// How many of a group's files have compiled, shown before each file as it starts +// How many of a group's files have compiled, shown before each file as it +// starts: a count, or with HXCPP_PROGRESS_PERCENT a percentage class Progress { var finished:Int; var total:Int; + var percent:Bool; - public function new(inTotal:Int) + public function new(inTotal:Int, inPercent = false) { finished = 0; total = inTotal; + percent = inPercent; } public function label():String { + if (percent) + { + // Pad to the width of 100.0% so the file names line up + var tenths = total > 0 ? Std.int(finished * 1000 / total) : 1000; + var done = Std.int(tenths / 10) + "." + (tenths % 10) + "%"; + while (done.length < 6) + done = done + " "; + return "\x1b[1m[" + done + "]\x1b[0m"; + } var done = Std.string(finished); while (done.length < Std.string(total).length) done = " " + done;