{"action":"opened","issue":{"url":"https://api.github.com/repos/ReubenBond/DeepCopy/issues/6","repository_url":"https://api.github.com/repos/ReubenBond/DeepCopy","labels_url":"https://api.github.com/repos/ReubenBond/DeepCopy/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/ReubenBond/DeepCopy/issues/6/comments","events_url":"https://api.github.com/repos/ReubenBond/DeepCopy/issues/6/events","html_url":"https://github.com/ReubenBond/DeepCopy/issues/6","id":271423572,"number":6,"title":"Clone of SimpleClass too slow","user":{"login":"Tornhoof","id":7989549,"avatar_url":"https://avatars1.githubusercontent.com/u/7989549?v=4","gravatar_id":"","url":"https://api.github.com/users/Tornhoof","html_url":"https://github.com/Tornhoof","followers_url":"https://api.github.com/users/Tornhoof/followers","following_url":"https://api.github.com/users/Tornhoof/following{/other_user}","gists_url":"https://api.github.com/users/Tornhoof/gists{/gist_id}","starred_url":"https://api.github.com/users/Tornhoof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tornhoof/subscriptions","organizations_url":"https://api.github.com/users/Tornhoof/orgs","repos_url":"https://api.github.com/users/Tornhoof/repos","events_url":"https://api.github.com/users/Tornhoof/events{/privacy}","received_events_url":"https://api.github.com/users/Tornhoof/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-06T10:20:36Z","updated_at":"2017-11-06T10:20:36Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hi, during benchmarking of #1 I noticed, that the SimpleClass clone is quite slow, due to the recording of the same instance logic.\r\nI benchmarked a  few different versions:\r\n- Your current one\r\n- Removing the context handling in the IL code\r\n- Removing the context handling and calling the delegate directly\r\n- Expression Tree version for properties I'm currently using\r\n- simply calling doing a ``new SimpleClass`` with the values (pure ctor and property assignment)\r\n\r\n|                    Method               |     Mean |     Error |    StdDev |  Gen 0 | Allocated |\r\n|-----------------------------------------|---------:|----------:|----------:|-------:|----------:|\r\n|                    SimpleClass_DeepCopy | 108.1 ns | 0.1503 ns | 0.1333 ns | 0.0122 |      64 B |\r\n|     SimpleClass_DeepCopy_WithoutContext | 41.70 ns | 0.1472 ns | 0.1305 ns | 0.0122 |      64 B |\r\n|\t  SimpleClass_Delegate_WithoutContext | 15.14 ns | 0.0216 ns | 0.0202 ns | 0.0122 |      64 B |\r\n|              SimpleClass_ExpressionTree | 58.47 ns | 0.8300 ns | 0.7357 ns | 0.0122 |      64 B |\r\n|                         SimpleClass_New | 7.969 ns | 0.0146 ns | 0.0136 ns | 0.0122 |      64 B |\r\n\r\nI think it might useful to find a way how to clone an object without the context and only handle the context if it's necessary.\r\nFor example:\r\nOnly add the context handling part for arrays, lists of classes etc (primitive types and structs shouldn't need it) and provide two versions, one for lists and one for direct calls\r\n\r\nI admit this might get ugly with nested objects, but nested objects usually are bigger so it won't impact as much, if at all, I guess having a fast path for plain and simple c# objects would nice."}}
{"actor":{"display_login":"Tornhoof"}}