How to efficiently save prefab transform position and rotation to csv

I need to save my camera position and rotation to csv recurrently (minimum rate would be about 10 times per second). I have come across solutions such as c# - Saving streamed Data from Unity in a csv File - Stack Overflow (pasted below)
But this slows down my app and the number of saves varies between about 8 to 15 times per second on my machine. Is there a more efficient way to iteratively save to csv ?

Best wishes,

void update()

string filePath = @"C:\Data.csv";
string delimiter = ",";

Vector3 leftGazeDirection = smiInstance.smi_GetLeftGazeDirection();
Vector3 rightGazeDirection = smiInstance.smi_GetRightGazeDirection();

float[][] output = new float[][]{
new float[]{leftGazeDirection.x},
new float[]{leftGazeDirection.y},
new float[]{leftGazeDirection.z},
new float[]{rightGazeDirection.x},
new float[]{rightGazeDirection.y},
new float[]{rightGazeDirection.z} };

int length = output.GetLength(0);

StringBuilder sb = new StringBuilder();
for (int index = 0; index < length; index++)
sb.AppendLine(string.Join(delimiter, output[index]));

File.WriteAllText(@"C:\Data.csv", sb.ToString());


In general you’ll have 2 options:

The first would be to use multithreading here.
While it is generally not advised to use any threading-realted stuff in unity it can be applied here i think as the task that you want to execute in a seperate thread would just write out information on the disk and not access any unity-stuff.

The second option depends a bit on your requirements. Afaik the bottleneck that you have is that a write-call itself is slow. So instead it might be smarter to buffer more data (for example over one second) and then write that data as a bulk. That however depends on what you want to do with that data. If it is supposed to be “live-readable” in a sense that you instantly can see the new position then that ofc is not a good idea.

2 and a half-ish option: In case that this still is not enough: write into binary format instead of csv and create a parser script in python or something for post-processing. Writing one float in characters instead of binary representation takes up about 10x more space and thus is 10x slower than binary.

Thank you for your help!