CopyTo
Copies all collected samples to the destination list.
Read time 1 minuteLast updated 8 days ago
Definition
- Type: Method
- Namespace: Unity.Profiling
- Assembly: UnityEngine.CoreModule
CopyTo(List<ProfilerRecorderSample>, bool)
Copies all collected samples to the destination list.
public void CopyTo(List<ProfilerRecorderSample> outSamples, bool reset = false)
Parameters
CopyTo(ProfilerRecorderSample*, int, bool)
Copies collected samples to the destination array.
public int CopyTo(ProfilerRecorderSample* dest, int destSize, bool reset = false)
Parameters
Pointer to the destination samples array.
Destination samples array size.
Reset ProfilerRecorder.
Returns
Type | Description |
|---|---|
| int | Returns the count of the copied elements. |
Examples
using Unity.Profiling;public class ExampleScript{ static double GetRecorderFrameAverage(ProfilerRecorder recorder) { var samplesCount = recorder.Capacity; if (samplesCount == 0) return 0; double r = 0; unsafe { var samples = stackalloc ProfilerRecorderSample[samplesCount]; recorder.CopyTo(samples, samplesCount); for (var i = 0; i < samplesCount; ++i) r += samples[i].Value; r /= samplesCount; } return r; }}