A game about forced loneliness, made by TACStudios
1using System;
2using System.Collections.Generic;
3using NUnit.Framework;
4using Unity.Collections;
5using Unity.PerformanceTesting;
6
7namespace Unity.Collections.PerformanceTests
8{
9 internal class NativeSlicePerformanceTests
10 {
11 [Test, Performance]
12 [Category("Performance")]
13 public void NativeSlice_Performance_CopyTo()
14 {
15 const int numElements = 16 << 10;
16
17 NativeArray<int> array = new NativeArray<int>(numElements, Allocator.Persistent);
18 var slice = new NativeSlice<int>(array, 0, numElements);
19
20 var copyToArray = new int[numElements];
21
22 Measure.Method(() =>
23 {
24 slice.CopyTo(copyToArray);
25 })
26 .WarmupCount(100)
27 .MeasurementCount(1000)
28 .Run();
29
30 array.Dispose();
31 }
32
33 [Test, Performance]
34 [Category("Performance")]
35 public void NativeSlice_Performance_CopyFrom()
36 {
37 const int numElements = 16 << 10;
38
39 NativeArray<int> array = new NativeArray<int>(numElements, Allocator.Persistent);
40 var slice = new NativeSlice<int>(array, 0, numElements);
41
42 var copyToArray = new int[numElements];
43
44 Measure.Method(() =>
45 {
46 slice.CopyFrom(copyToArray);
47 })
48 .WarmupCount(100)
49 .MeasurementCount(1000)
50 .Run();
51
52 array.Dispose();
53 }
54 }
55}