Example #1
0
    void Update()
    {
        _log.Update();
        _appendLog.Update();
        _frametimeWatcher.Update();
        if (_testing)
        {
            _maxMemory = Mathf.Max(_maxMemory, (int)UnityEngine.Profiling.Profiler.GetTotalAllocatedMemoryLong());
            _maxSpike  = Mathf.Max(_maxSpike, _frametimeWatcher.maxFrameTime);
        }
        var mode = (Mode)_modeDropdown.value;

        if (_enumerator != null)
        {
            if (!_enumerator.MoveNext())
            {
                _enumerator = null;

                string msg = mode + " : " + _time.ToString("F2");
                if (mode != Mode.WwwSyncWrite)
                {
                    int slotCount;
                    int.TryParse(_parallelCountInputField.text, out slotCount);
                    slotCount = Mathf.Max(slotCount, 1);
                    msg      += " Parallel: " + slotCount;
                    msg      += " Shuffle: " + _shuffleToggle.isOn;
                    msg      += " MaxSpike: " + _maxSpike;
                    msg      += " MaxMem: " + (_maxMemory / (1024 * 1024));
                }
                if (mode == Mode.UwrAsyncWrite)
                {
                    int writerBufferSize;
                    int.TryParse(_writerBufferSizeInputField.text, out writerBufferSize);
                    writerBufferSize  = Mathf.Max(writerBufferSize, 1);
                    writerBufferSize *= 1024;
                    int inputBufferSize;
                    int.TryParse(_inputBufferSizeInputField.text, out inputBufferSize);
                    inputBufferSize  = Mathf.Max(inputBufferSize, 1);
                    inputBufferSize *= 1024;
                    msg             += " WriterBufferSize: " + writerBufferSize;
                    msg             += " InputBufferSize: " + inputBufferSize;
                }
                Debug.Log(msg);
            }
        }

        _fpsText.text = _frametimeWatcher.averageFrameTime.ToString() + " MaxSpike: " + _maxSpike.ToString() + " Time: " + _time.ToString("F2") + " MaxMem: " + (_maxMemory / (1024 * 1024));
        var restBytes = (_writer != null) ? _writer.restBytes : 0;

        _stateText.text      = string.Format("FileCount:{0}/{1} Read:{2} RestWrite:{3}", _doneFileCount, _totalFileCount, _doneBytes, restBytes);
        _button.interactable = (_enumerator == null);
        _inputBufferSizeInputField.interactable  = (mode == Mode.UwrAsyncWrite);
        _writerBufferSizeInputField.interactable = (mode == Mode.UwrAsyncWrite);
    }
Example #2
0
    void Update()
    {
        _log.Update();

        if (_loader.ready)         // 見ないでUpdate,Dumpを呼べば、初期化が終わるまでブロックするが動く。ブロックを嫌うならこれを見ておくこと。
        {
            _loader.Update();
            _sb.Length = 0;
            bool summaryOnly = (_fileList.Count > 20);
            _loader.Dump(_sb, summaryOnly);
            dump.text = _sb.ToString();
        }

        // 破棄中は何もしない
        int sinceRelease = Time.frameCount - _releasedFrame;

        if (sinceRelease == (_releaseWait / 2))
        {
            System.GC.Collect();             // GC走らせて素材消す
        }
        else if (sinceRelease == _releaseWait)
        {
            if (autoTestToggle.isOn)             // 自動なら一定確率でキャッシュ消す
            {
                if (UnityEngine.Random.Range(0f, 1f) < 0.5f)
                {
                    ClearStorageCache();
                }
            }
        }
        if (sinceRelease < _releaseWait)
        {
            return;
        }

        if (autoTestToggle.isOn)
        {
            Load();
            if (UnityEngine.Random.Range(0f, 1f) < 0.1f)
            {
                Release();
            }
            if (UnityEngine.Random.Range(0f, 1f) < 0.1f)
            {
                if (!_listFileExists)
                {
                    UpdateHashMap();
                }
            }
        }
    }