I did a quick test to compare ES2Writer.Write (sequentially without tag) with ES3File.Save.
All settings are configured to default.
My first results are particularly bad. ES3 seems 10X slower than ES2.
Here is a sample code (Results on my PC => ES2 : about 15ms, ES3 : about 150ms)
Code: Select all
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
public class testSaves : MonoBehaviour
{
void Start ()
{
// ES3 Save ********************************************
ES3File file = new ES3File("myFile.es3");
Stopwatch codeTimer = new Stopwatch();
codeTimer.Start();
for (int i = 0; i < 1000; i++)
{
file.Save<Transform>("myGUID", transform);
//file.Save<string>("myGUID", "string test");
}
file.Sync();
codeTimer.Stop();
UnityEngine.Debug.Log("Time taken to save the Transform with ES3 : " + codeTimer.ElapsedMilliseconds);
// ES2 Save ********************************************
ES2Writer writer = ES2Writer.Create("myFile.txt");
codeTimer.Reset();
codeTimer.Start();
for (int i = 0; i < 1000; i++)
{
writer.Write(this.transform);
//writer.Write("string test");
}
writer.Save(false);
writer.Dispose();
codeTimer.Stop();
UnityEngine.Debug.Log("Time taken to save the Transform with ES2 : " + codeTimer.ElapsedMilliseconds);
}
}
I have to save a lot of components (transform, audioSource, sprites, rigidbodies, colliders, tags, layers, custom components, other assets components ...).
I can save almost anytime and I want to avoid any lag.
Currently, I have relatively good performance using a customized version of ES2UniqueID and sequentially writing my data (ES2Writer.Write <T> (T data)).
I wanted to move to ES3 to take advantage of some new features and especially to ensure support and its compatibility with future versions of Unity.
My question is the following.
Is it planned to have in ES3 a sequential writing as efficient as in ES2?
Thank you in advance for your answer.
Best regards.
Guillaume (a french guy - sorry for my poor english)