Example #1
0
    public void WriteLogToFile()
    {
        if (Application.isMobilePlatform || m_bRecord)
        {
            if (timingDic.Count != 0)
            {
                Debug.LogWarning("--WriteLogToFile-->" + timingDic.Count);
            }

            foreach (var item in scnRecord)
            {
                SceneTimeInfo st  = item.Value;
                string        str = string.Format("scid:{0},key:{1},num:{2},times:{3}", st.scneid, st.key, st.num, st.times);
                if (st.num > 0)
                {
                    str += " avt:" + (st.times / st.num).ToString();
                }
                LuaInterface.Debugger.Log(str);
            }

            //StreamWriter sw = null;
            //sw = new StreamWriter(Best.BundleConfig.Instance.BundlesPathForPersist + "loadtime.txt");
            //sw.WriteLine("");
            //sw.WriteLine("记录时间:" + System.DateTime.Now);

            //foreach (string item in logList)
            //{
            //    sw.WriteLine(item);
            //}

            //foreach (var item in timeRecord)
            //{
            //    string str = string.Format("key:{0},num:{1},val:{2}", item.Key, item.Value.num, item.Value.times);
            //    sw.WriteLine(str);
            //}

            //foreach (var item in scnRecord)
            //{
            //    SceneTimeInfo st = item.Value;
            //    string str = string.Format("scid:{0},key:{1},num:{2},times:{3}",st.scneid,st.key,st.num,st.times);
            //    if (st.num > 0)
            //        str += " avt:" + (st.times / st.num).ToString();
            //    sw.WriteLine(str);
            //}

            //sw.Flush();
            //sw.Close();
        }
    }
Example #2
0
    public void WriteLog(uint sceneid, eTimeCost e, bool begin = true)
    {
        int id = (int)sceneid << 16 | (int)e;

        if (!scnRecord.ContainsKey(id))
        {
            scnRecord[id] = new SceneTimeInfo();
        }
        SceneTimeInfo st = scnRecord[id];

        st.key    = e;
        st.scneid = (int)sceneid;
        if (begin)
        {
            st.beginTime = Time.realtimeSinceStartup;
        }
        else
        {
            st.endTime = Time.realtimeSinceStartup;
            st.times  += (st.endTime - st.beginTime);
            st.num++;
        }
    }