src: use ostringstream instead of string in FromFilePath()#50253
src: use ostringstream instead of string in FromFilePath()#50253pluris wants to merge 1 commit intonodejs:mainfrom
FromFilePath()#50253Conversation
|
Review requested:
|
|
What is the performance impact of the new proposed change? Did you had any chance to benchmark it? |
|
I ran |
|
I ran my own benchmarks. Please see my blog post: For processing strings, streams in C++ can be slow Here is the gist:
I understand that there has been performance engineering guided by the belief that streams in C++ are efficient. My recommendation is to re-assess this belief and conduct benchmarks. In fact, it is entirely possible that removing streams where they have been added could be a strategy to improve performance. For benchmarking, I recommend using relatively large inputs. Here is why: Benchmarking is hard: processors learn to predict branches. |
|
@lemire Thanks for the good information. This |
When performing string concatenation operations, it is more advantageous in terms of performance to use
std::ostringstreamrather thanstd::string. This approach is also used elsewhere, such asdebug_utilsandnode_errors.Refs: #46410