fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Runtime.Serialization.Formatters.Binary;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. List<Int32> lista = new List<Int32>();
  11.  
  12. for(Int32 i = 0; i < 100000; ++i) {
  13. lista.Add(i);
  14. }
  15.  
  16. Dictionary<Int32,Boolean> map = new Dictionary<Int32,Boolean>();
  17. for(Int32 i = 0; i < 100000; ++i) {
  18. map.Add(i, true);
  19. }
  20.  
  21. long listSize = 0;
  22. long mapSize = 0;
  23.  
  24. using (Stream s = new MemoryStream()) {
  25. BinaryFormatter formatter = new BinaryFormatter();
  26. formatter.Serialize(s, lista);
  27. listSize = s.Length;
  28. }
  29. using (Stream s = new MemoryStream()) {
  30. BinaryFormatter formatter = new BinaryFormatter();
  31. formatter.Serialize(s, map);
  32. mapSize = s.Length;
  33. }
  34.  
  35. Console.WriteLine(String.Format("Lista: {0} bytes", listSize));
  36. Console.WriteLine(String.Format("Mapa: {0} bytes", mapSize));
  37.  
  38. }
  39. }
Success #stdin #stdout 0.48s 26632KB
stdin
Standard input is empty
stdout
Lista: 524493 bytes
Mapa: 1401237 bytes