Comments (3)
I went ahead a tried to get some data.
For MSVC 14.31.31103 (VS 2022 17.1) using /Bt+
and given the following code:
constexpr auto repeat(std::string_view str, size_t count)
{
std::string result;
for (size_t i = 0; i < count; ++i)
{
result += str;
}
return result;
}
int main()
{
static constexpr auto TEST = to_string_view(
[]
{
return repeat(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore "
"et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut "
"aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse "
"cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa "
"qui officia deserunt mollit anim id est laborum.",
15);
});
fmt::print("{}", TEST);
}
My version (c1xx.dll is compiler frontend and c2.dll backend):
Debug
[build] time(C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\c1xx.dll)=1.40770s < 262926248496 - 262940325518 > BB
[build] time(C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\c2.dll)=0.00985s < 262940328476 - 262940426948 > BB
Release
[build] time(C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\c1xx.dll)=1.38381s < 262677700111 - 262691538237 > BB
[build] time(C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\c2.dll)=0.01516s < 262691539825 - 262691691389 > BB
and your version:
Debug
[build] time(C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\c1xx.dll)=1.04090s < 261748439353 - 261758848310 > BB
[build] time(C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\c2.dll)=0.00958s < 261758851469 - 261758947317 > BB
Release
[build] time(C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\c1xx.dll)=1.01833s < 262397415096 - 262407598432 > BB
[build] time(C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\c2.dll)=0.01552s < 262407599893 - 262407755112 > BB
So it seems that there isn't as much memoization as I was expecting, at least in the case of MSVC.
from tools.
I expect no memoization unless it is passed as a template parameter, which is why I implemented this solution.
from tools.
With the advent of more and more constexpr evaluated code, compilers should probably start to add some optimization passes to such code. In my example above it seems that the call to repeat
takes almost 400ms, quite a lot. Even in Debug mode, the same code evaluated at runtime would probably not take more than 10ms.
from tools.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tools.