Last active
June 6, 2017 23:07
Revisions
-
stephentoub renamed this gist
Jun 6, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
stephentoub created this gist
Jun 6, 2017 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Runtime.Serialization.Formatters.Binary; class Test { static void Main() { var books = new List<Book>(); for (int i = 0; i < 1_000_000; i++) { string id = i.ToString(); books.Add(new Book { Name = id, Id = id }); } var formatter = new BinaryFormatter(); var mem = new MemoryStream(); formatter.Serialize(mem, books); mem.Position = 0; var sw = Stopwatch.StartNew(); formatter.Deserialize(mem); sw.Stop(); Console.WriteLine(sw.Elapsed.TotalSeconds); } [Serializable] private class Book { public string Name; public string Id; } }