Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleApp1
  5. {
  6. class Program
  7. {
  8.  
  9.  
  10. static byte []array=new byte [16];
  11.  
  12.  
  13.  
  14. static Span<byte> getSpan ()
  15. {
  16.     return new Span<byte> (array,4,8);
  17. }
  18.  
  19.  
  20.  
  21. static void Main(string[] args)
  22. {
  23.     Console.WriteLine ($"Start GC: {GC.CollectionCount(0)}");
  24.  
  25.     for (int i=0;i<10_000_000;i++)
  26.     {
  27.         getSpan();
  28.     }
  29.  
  30.     Console.WriteLine ($"End GC: {GC.CollectionCount(0)}");
  31.     Console.ReadKey();
  32. }
  33.  
  34.  
  35.  
  36. }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement