Skip to content

Instantly share code, notes, and snippets.

@baba-s
Created January 10, 2016 01:38
Show Gist options
  • Save baba-s/d6b46fe4baac6a162695 to your computer and use it in GitHub Desktop.
Save baba-s/d6b46fe4baac6a162695 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections.Generic;
using System.Text;
public class Loader : MonoBehaviour
{
private string result;
private void OnGUI()
{
if ( GUILayout.Button( "Start" ) )
{
var builder = new StringBuilder();
builder.AppendLine( Test( 1000 ) );
builder.AppendLine( Test( 10000 ) );
builder.AppendLine( Test( 100000 ) );
var str = builder.ToString();
Debug.Log( str );
result = str;
}
GUILayout.Label( result );
}
private string Test( int num )
{
var dir = num.ToString();
var builder = new StringBuilder();
builder.AppendFormat( "■{0}件", num ).AppendLine();
var textAsset = Resources.Load<TextAsset>( dir + "/status_master" );
var statusMaser = Resources.Load<StatusMaster>( dir + "/status_master" );
{
var startTime = Time.realtimeSinceStartup;
var list = new List<Status>();
var text = textAsset.text;
var row = text.Split( '\n' );
for ( int i = 0; i < row.Length; i++ )
{
var column = row[ i ].Split( ',' );
var status = new Status
{
dex_no = int.Parse( column[ 0 ] ),
name = column[ 1 ],
type1 = ( TYPE )( int.Parse( column[ 2 ] ) ),
type2 = ( TYPE )( int.Parse( column[ 3 ] ) ),
ot = column[ 4 ],
id_no = int.Parse( column[ 5 ] ),
exp_points = int.Parse( column[ 6 ] ),
exp_to_next_lv = int.Parse( column[ 7 ] ),
hp_current = int.Parse( column[ 8 ] ),
hp_max = int.Parse( column[ 9 ] ),
attack = int.Parse( column[ 10 ] ),
defense = int.Parse( column[ 11 ] ),
attack_sp = int.Parse( column[ 12 ] ),
defense_sp = int.Parse( column[ 13 ] ),
speed = int.Parse( column[ 14 ] ),
arena_trap_name = int.Parse( column[ 15 ] ),
arena_trap_detail = int.Parse( column[ 16 ] ),
};
list.Add( status );
}
var time = Time.realtimeSinceStartup - startTime;
builder.AppendFormat( "CSV: {0}", time ).AppendLine();
}
{
var startTime = Time.realtimeSinceStartup;
var list = new List<Status>( statusMaser.statuses );
var time = Time.realtimeSinceStartup - startTime;
builder.AppendFormat( "ScriptableObject: {0}", time ).AppendLine();
}
return builder.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment