loopy pedestrian✍🏿 on Nostr: >replacing character with string in-place in std::string takes 400ms >appending to ...
>replacing character with string in-place in std::string takes 400ms
>appending to new std::ostringstream instead of replacing in-place takes 100ms
>same thing but with .append() calls to new string takes 15ms
i guess replacing in-place does some iterator invaidation and inserting and probably lots of memory gets copies there
the 100-15ms difference between streams and just a string is because of virtual calls, probably. didnt know it could make this much of a difference
Published at
2023-10-03 11:29:28Event JSON
{
"id": "17fdb4ffe0af3a0e6073872591e827daa5850e55f9b6971b7d2653a851ab0b31",
"pubkey": "d622efd3f5df967391fd37796b85eb369a6f693e4e1e9fe2d13bd7b35ce86e09",
"created_at": 1696332568,
"kind": 1,
"tags": [
[
"proxy",
"https://clubcyberia.co/objects/4366e2be-89c1-43a7-8480-1b10d1225a22",
"activitypub"
]
],
"content": "\u003ereplacing character with string in-place in std::string takes 400ms\n\u003eappending to new std::ostringstream instead of replacing in-place takes 100ms\n\u003esame thing but with .append() calls to new string takes 15ms\ni guess replacing in-place does some iterator invaidation and inserting and probably lots of memory gets copies there\nthe 100-15ms difference between streams and just a string is because of virtual calls, probably. didnt know it could make this much of a difference",
"sig": "405acb4867aa376340260cda2c9bfbbc4a316179a79672bc955e0b0850b63056ce0a32199737fa7bda6741e625b162d398c08c48b96e79b3d3748d47abaca2f7"
}