Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Why is DataConnection.New() slow

$
0
0
I was benchmarking the Composite DataConnection class, so consider the following code :
var userList = new List<RegisteredUsers>();
            using (DataConnection connection = new DataConnection())
            {
                for (int i = 0; i < (100000); i++)
                {
                    var user = DataConnection.New<RegisteredUsers>();

                    user.Id = Guid.NewGuid();
                    user.Name = "John";
                    user.LastName = "Doe";
                    user.Email = "john.doe@ay.com";
                    user.Password = "rawr";
                    userList.Add(user);
                }

                connection.Add<RegisteredUsers>(userList);
            }
I create a list of 100,000 elements via C# using the DataConnection.New<T>() method and save it using the connection.Add

The slowest part of this script is the creation of the empty user.

Saving the list takes less than a second but generating the list takes more than 1 min 30 seconds.

Do anyone of you know why ? Is there a more effeciant way of doing that ?

Thanks.

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>