Dne 1. 4. 2015 v 10:13 Mattias Engdegård napsal(a): > 1 apr 2015 kl. 05.35 skrev Dongsheng Song <dongsheng.s...@gmail.com>: > >> In my testing, getenv() is very fast. >> >> *) unset PRINTF_EXPONENT_DIGITS >> >> preheat 10000 times, then perform 1000000 times (use 4.67777 seconds) >> getenv cost: 4.67777 us >> >> *) set PRINTF_EXPONENT_DIGITS=3 >> preheat 10000 times, then perform 1000000 times (use 3.41991 seconds) >> getenv: 3.41991 us > > 4 µs is a lot on a modern CPU, and an unacceptable overhead for a basic > library function such as sprintf.
If I assume getenv() iterates over complete environment in most cases (when PRINTF_EXPONENT_DIGITS is not set), then there is probably much worse overhead in a real world programs which is not likely covered in a trivial test program. The function getenv() shall replace data in CPU cache, which are likely useful for the ongoing program computation, with a lot of junk (the complete process environment). Morous ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public