Example #1
0
    /// <summary>
    /// 创建面板,请求资源管理器
    /// </summary>
    /// <param name="type"></param>
    public void CreatePanel(string path, int weight, LuaFunction func = null)
    {
        string name = Path.GetFileNameWithoutExtension(path);

        if (uiList.GetValue(path) != null)
        {
            return;
        }

        AssetWidget uiWidget = new AssetWidget(path, weight, (ao) =>
        {
            var prefab = ao.GetAsset <GameObject>();
            if (prefab == null)
            {
                Debug.LogError(string.Format("Panel load error: no panel founded! {0}, {1}", ao.assetPath, name));
                return;
            }
            GameObject go = Instantiate(prefab) as GameObject;
            go.name       = name;
            go.layer      = LayerMask.NameToLayer("UI");
            go.transform.SetParent(FindParent().transform, false);
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = Vector3.zero;
            LuaBehaviour behaviour     = go.transform.GetOrAddComponent <LuaBehaviour>();
            behaviour.OnInit();
            PanelData panelData;
            try
            {
                panelData = poolManager.Get <PanelData>();
            }
            catch
            {
                panelData = new PanelData();
            }
            panelData.Name        = name;
            panelData.Weight      = weight;
            panelData.PanelObject = go;
            panelData.behaviour   = behaviour;
            uiList.Put(name, panelData);
            uiShowList.Add(name);
            if (func != null)
            {
                func.Call(go);
            }
            _curShowPanel = name;
            _curDepth++;
            panelData.AddOrder(_curDepth);
            Debug.LogWarning("CreatePanel::>> " + name + " " + prefab);
        });

        panelLoader.LoadAsset(uiWidget);
    }
Example #2
0
        void Test(int t, int n, ISchedule schedule, string scheduleName)
        {
            var graph = new GraphGenerator(1000, 600);
            var Listk = new List <int> {
                10, 9, 8, 7, 6, 5
            };

            Listk = Listk.Select(x => n / x).Distinct().ToList();

            var fifol = new List <double>();
            var fwfl  = new List <double>();
            var lrul  = new List <double>();
            var lful  = new List <double>();
            var randl = new List <double>();
            var rmal  = new List <double>();

            Listk.ForEach(k =>
            {
                int fifoc, fwfc, lruc, lfuc, randc, rmac;
                fifoc = fwfc = lruc = lfuc = randc = rmac = 0;

                for (int j = 0; j < 100; j++)
                {
                    var fifo = new FIFOCache(k);
                    var fwf  = new FWFCachecs(k);
                    var lru  = new LRUCache(k);
                    var lfu  = new LFUCache(k);
                    var rand = new RandCache(k);
                    var rma  = new RMACache(k);

                    for (int i = 0; i < t; i++)
                    {
                        var x  = schedule.GetNextNumber();
                        fifoc += fifo.GetValue(x);
                        fwfc  += fwf.GetValue(x);
                        lruc  += lru.GetValue(x);
                        lfuc  += lfu.GetValue(x);
                        randc += rand.GetValue(x);
                        rmac  += rma.GetValue(x);
                    }
                }
                fifol.Add(fifoc / 100);
                fwfl.Add(fwfc / 100);
                lrul.Add(lruc / 100);
                lful.Add(lfuc / 100);
                randl.Add(randc / 100);
                rmal.Add(rmac / 100);
            });
            var kk = Listk.Select(x => (double)x).ToList();

            graph.AddSeries($"{scheduleName}_FIFO_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, fifol, Color.Red);
            graph.AddSeries($"{scheduleName}_FWF_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, fwfl, Color.Blue);
            graph.AddSeries($"{scheduleName}_LRU_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, lrul, Color.Black);
            graph.AddSeries($"{scheduleName}_LFU_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, lful, Color.Yellow);
            graph.AddSeries($"{scheduleName}_RAND_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, randl, Color.Green);
            graph.AddSeries($"{scheduleName}_RMA_", System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, kk, rmal, Color.MediumPurple);

            graph.SaveGraph($"{scheduleName}_{n}_3");
        }