[TIL] 82 CSV ,ProFiler โญโญ

์—…๋ฐ์ดํŠธ:

์นดํ…Œ๊ณ ๋ฆฌ:

ํƒœ๊ทธ: , ,


CSV, ProFiler



์ตœ์ข… ํŒ€ ํ”„๋กœ์ ํŠธ 24์ผ์ฐจ

ย ย  [o] ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ - 53
ย ย  [o] ๋ฉด์ ‘ ๋ฌธ์ œ ํ’€๊ธฐ - 5
ย ย  [o] 1,2๋ฐ˜ ๋งˆ๋ฌด๋ฆฌ์ •๋ฆฌ ์ฑŒ~
ย ย  [x] ์‹ฌํ™”์ฃผ์ฐจ ๊ฐ•์˜ ๋“ฃ๊ธฐ.
ย ย  [x] ๋””์ž์ธ ์ฝ”๋“œ ํŒจํ„ด ์ดํ•ด,์ •๋ฆฌํ•˜๊ธฐ.
ย ย  [x] ์ž๋ฃŒ๊ตฌ์กฐ ๋””์ž์ธํŒจํ„ด ๊ฐ•์˜ ๋‹ค์‹œ ๋“ฃ๊ธฐ.







๊ฐ„๋‹จํ•œ CSV ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

๋กœ๋”ฉ์”ฌ TIP ๋ถ€๋ถ„์— ์“ฐ๊ธฐ์œ„ํ•œ CSV์‚ฌ์šฉ , ๋ถˆ๋Ÿฌ์˜ค๊ธฐ CSVReader ์Šคํฌ๋ฆฝํŠธ ์ฐธ์กฐ
image

CSVReader.cs

using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;

public class CSVReader
{
    static string SPLIT_RE = @",(?=(?:[^""]*""[^""]*"")*(?![^""]*""))";
    static string LINE_SPLIT_RE = @"\r\n|\n\r|\n|\r";
    static char[] TRIM_CHARS = { '\"' };

    public static List<Dictionary<string, object>> Read(string file)
    {
        var list = new List<Dictionary<string, object>>();
        TextAsset data = Resources.Load(file) as TextAsset;

        var lines = Regex.Split(data.text, LINE_SPLIT_RE);

        if (lines.Length <= 1) return list;

        var header = Regex.Split(lines[0], SPLIT_RE);
        for (var i = 1; i < lines.Length; i++)
        {

            var values = Regex.Split(lines[i], SPLIT_RE);
            if (values.Length == 0 || values[0] == "") continue;

            var entry = new Dictionary<string, object>();
            for (var j = 0; j < header.Length && j < values.Length; j++)
            {
                string value = values[j];
                value = value.TrimStart(TRIM_CHARS).TrimEnd(TRIM_CHARS).Replace("\\", "");
                object finalvalue = value;
                int n;
                float f;
                if (int.TryParse(value, out n))
                {
                    finalvalue = n;
                }
                else if (float.TryParse(value, out f))
                {
                    finalvalue = f;
                }
                entry[header[j]] = finalvalue;
            }
            list.Add(entry);
        }
        return list;
    }
}

๋ถˆ๋Ÿฌ์˜ค๊ธฐ
List<Dictionary<string, object>> data_Dialog = CSVReader.Read("CSV/Tip");
_randomIndex = Random.Range(0, data_Dialog.Count);
_tipText.text = (data_Dialog[_randomIndex]["Tip"].ToString());


image

๋ถˆ๋Ÿฌ์˜ค๊ธฐ๋Š” ๋œ๋‹ค. ๋‹ค์Œ์— ๋” ๋งŽ์€๋ฐ์ดํ„ฐ๋‚˜ ๋Œ€ํ™”ํ˜•์‹์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ• ๋•Œ ์ข€ ๋” ๊ณต๋ถ€.







ํ”„๋กœํŒŒ์ผ๋Ÿฌ(ProFiler)

๋˜‘๊ฐ™์€ metarial -> enable gpuinstance ๊ฐ™์€ matarial์„ ํ•œ๋ฒˆ์— ๋“œ๋กœ์šฐ์ฝœ๋กœ ๋„˜๊ธด๋‹ค.
์™ผ์ชฝ์— ์ฒดํฌํ•ด์„œ ํ•ด๋‹น ๋‚ด์—ญ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.
ํ•˜๋‹จ์ขŒ์ธก timeline, hierarchy
์ตœ์ ํ™” ํ•  ์š”์†Œ ์ฐพ๊ธฐ.
ํ•ต์‹ฌ gfx waitforpresent~~~ -> gpu ๊ฐ€ ๊ธฐ๋‹ค๋ฆฌ๊ณ  ์žˆ๋‹ค -> ๋ Œ๋”๋ง ์ตœ์ ํ™” ํ•„์š”
ํ•ต์‹ฌ gfx waitforcommand~~~ -> cpu๊ฐ€ ๋ฐ”๋น ์„œ ๋ช…๋ น์„ ๊ธฐ๋‹ค๋ฆฌ๊ณ ์žˆ๋‹ค -> cpu์ตœ์ ํ™” ํ•ด์•ผ๋œ๋‹ค
์„ธ๋ถ€์ ์œผ๋กœ ๋ณผ๋ ค๋ฉด ์ƒ๋‹จ์— deep profile ํ™œ์„ฑํ™” ํ•˜๋‹จ์šฐ์ธก ์— ์ฒดํฌ ๋‹ค ํ•˜๊ธฐ.

๋งˆ์ปค using.profiling
public static readonly profilermarker mymarker = new profilemarker(โ€œmymarkerโ€);
mymarker.begin ~ mymarker.end ๊นŒ์ง€์˜๋ฅผ ์ฒดํฌํ•  ์ˆ˜ ์žˆ๋‹ค.
๋นŒ๋“œ์—์„œ development build-> auto profiler ์ฒดํฌ ์‹œ ์—๋””ํ„ฐ ๋นผ๊ณ  ํ”„๋กœํŒŒ์ผ ๊ฐ€๋Šฅ.







์žก๋‹ด,์ •๋ฆฌ

CSV, ํ”„๋กœํŒŒ์ผ๋Ÿฌ




์ฐธ๊ณ  : ์œ ๋‹ˆํ‹ฐ TOP




๐Ÿ“”

๋Œ“๊ธ€๋‚จ๊ธฐ๊ธฐ