❔ Optimize Serializing of the List
Currently I do it like this, but is very slow.
var json = JsonConvert.SerializeObject(allUsers, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
The List allUsers
is a list of UserPrincipal and have around 1000 elements. The serialization takes are 90 seconds, which I think its a bit too much for a list like that. Is there any way I can optimize that?5 Replies
that's insanely unreasonable. is that class nested a lot?
Uhm idk, i doesnt look that complexed..
https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.accountmanagement.userprincipal?view=dotnet-plat-ext-7.0
UserPrincipal Class (System.DirectoryServices.AccountManagement)
Encapsulates principals that are user accounts.
you should maybe make your own user class with less data, that one looks like it does a lot more than just contain a bit info about a user
i dont think the serialization is slow, but getting all the properties is, bcuz they might be doing more than just return a value
yeah looks like this is the problem..
I created an empty list of dict<string,string>, and then add each property name:value to it, and it took 90 seconds to create that list as well..
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.