コード例 #1
0
        internal void AddModule(string module, bool appendModuleToName = true)
        {
            string text = (!appendModuleToName) ? module : StrippingInfo.ModuleName(module);
            string arg  = string.Format("com.unity.modules.{0}", module.ToLower());

            if (!this.modules.Contains(text))
            {
                this.modules.Add(text);
            }
            if (!this.sizes.ContainsKey(text))
            {
                this.sizes[text] = 0;
            }
            if (!this.icons.ContainsKey(text))
            {
                this.SetIcon(text, string.Format("package/{0}", arg));
            }
        }
コード例 #2
0
        internal static StrippingInfo GetBuildReportData(BuildReport report)
        {
            StrippingInfo result;

            if (report == null)
            {
                result = null;
            }
            else
            {
                StrippingInfo[] appendices = report.GetAppendices <StrippingInfo>();
                if (appendices.Length > 0)
                {
                    result = appendices[0];
                }
                else
                {
                    StrippingInfo strippingInfo = ScriptableObject.CreateInstance <StrippingInfo>();
                    report.AddAppendix(strippingInfo);
                    result = strippingInfo;
                }
            }
            return(result);
        }
コード例 #3
0
        public void Analyze()
        {
            var doSourceCodeAnalysis = Unsupported.IsDeveloperMode();

            var symbolArtifacts   = GetSymbolArtifacts();
            var moduleArtifacts   = GetModuleArtifacts();
            var assemblyArtifacts = GetIl2CPPAssemblyMapArtifacts(MethodMapPath);

            int moduleAccounted = 0;

            var functionSizes = GetFunctionSizes();

            Regex moduleNameParser = new Regex(@"WebGLSupport_(.*)Module_Dynamic", RegexOptions.IgnoreCase);

            foreach (var functionSize in functionSizes)
            {
                if (symbolArtifacts.ContainsKey(functionSize.Key))
                {
                    var objectFile = symbolArtifacts[functionSize.Key].Replace('\\', '/');
                    if (doSourceCodeAnalysis)
                    {
                        if (!objectSizes.ContainsKey(objectFile))
                        {
                            objectSizes[objectFile] = 0;
                        }
                        objectSizes[objectFile] += functionSize.Value;
                    }
                    if (objectFile.LastIndexOf('/') != -1)
                    {
                        var objectFolder = objectFile.Substring(0, objectFile.LastIndexOf('/'));
                        if (!folderSizes.ContainsKey(objectFolder))
                        {
                            folderSizes[objectFolder] = 0;
                        }
                        folderSizes[objectFolder] += functionSize.Value;
                    }
                }
                if (moduleArtifacts.ContainsKey(functionSize.Key))
                {
                    Match  m          = moduleNameParser.Match(moduleArtifacts[functionSize.Key]);
                    string moduleName = m.Success ? StrippingInfo.ModuleName(m.Groups[1].ToString()) : moduleArtifacts[functionSize.Key];

                    if (!moduleSizes.ContainsKey(moduleName))
                    {
                        moduleSizes[moduleName] = 0;
                    }

                    moduleSizes[moduleName] += functionSize.Value;

                    moduleAccounted += functionSize.Value;
                }
                if (assemblyArtifacts.ContainsKey(functionSize.Key))
                {
                    var assembly = assemblyArtifacts[functionSize.Key];
                    if (!assemblySizes.ContainsKey(assembly))
                    {
                        assemblySizes[assembly] = 0;
                    }

                    assemblySizes[assembly] += functionSize.Value;
                }
            }

            AddPlatformSpecificCodeOutputModules();

            int unaccounted = totalSize;

            foreach (var moduleSize in moduleSizes)
            {
                if (modules.Contains(moduleSize.Key))
                {
                    unaccounted -= moduleSize.Value;
                }
            }

            moduleSizes["Unaccounted"] = unaccounted;
            AddModule("Unaccounted", false);
            foreach (var moduleSize in moduleSizes)
            {
                AddModuleSize(moduleSize.Key, moduleSize.Value);
            }

            int totalAssemblySize = 0;

            foreach (var assemblySize in assemblySizes)
            {
                RegisterDependency("IL2CPP Generated", assemblySize.Key);
                sizes[assemblySize.Key] = assemblySize.Value;
                totalAssemblySize      += assemblySize.Value;
                SetIcon(assemblySize.Key, "class/DefaultAsset");
            }
            RegisterDependency("IL2CPP Generated", "IL2CPP Unaccounted");
            sizes["IL2CPP Unaccounted"] = moduleSizes["IL2CPP Generated"] - totalAssemblySize;
            SetIcon("IL2CPP Unaccounted", "class/DefaultAsset");

            if (doSourceCodeAnalysis)
            {
                System.Console.WriteLine("Code size per module: ");
                PrintSizesDictionary(moduleSizes);
                System.Console.WriteLine("\n\n");

                System.Console.WriteLine("Code size per source folder: ");
                PrintSizesDictionary(folderSizes);
                System.Console.WriteLine("\n\n");

                System.Console.WriteLine("Code size per object file: ");
                PrintSizesDictionary(objectSizes);
                System.Console.WriteLine("\n\n");

                System.Console.WriteLine("Code size per function: ");
                PrintSizesDictionary(functionSizes);
                System.Console.WriteLine("\n\n");
            }
        }
コード例 #4
0
        public void Analyze()
        {
            var doSourceCodeAnalysis = Unsupported.IsDeveloperMode();

            var symbolArtifacts   = GetSymbolArtifacts();
            var moduleArtifacts   = GetModuleArtifacts();
            var assemblyArtifacts = GetIl2CPPAssemblyMapArtifacts("Temp/StagingArea/Data/il2cppOutput/Symbols/MethodMap.tsv");

            int moduleAccounted = 0;

            var functionSizes = GetFunctionSizes();

            foreach (var functionSize in functionSizes)
            {
                if (symbolArtifacts.ContainsKey(functionSize.Key))
                {
                    var objectFile = symbolArtifacts[functionSize.Key].Replace('\\', '/');
                    if (doSourceCodeAnalysis)
                    {
                        if (!objectSizes.ContainsKey(objectFile))
                        {
                            objectSizes[objectFile] = 0;
                        }
                        objectSizes[objectFile] += functionSize.Value;
                    }
                    if (objectFile.LastIndexOf('/') != -1)
                    {
                        var objectFolder = objectFile.Substring(0, objectFile.LastIndexOf('/'));
                        if (!folderSizes.ContainsKey(objectFolder))
                        {
                            folderSizes[objectFolder] = 0;
                        }
                        folderSizes[objectFolder] += functionSize.Value;
                    }
                }
                if (moduleArtifacts.ContainsKey(functionSize.Key))
                {
                    var objectFile = moduleArtifacts[functionSize.Key];
                    objectFile = objectFile.Substring(0, objectFile.Length - "Module_Dynamic.bc".Length);
                    objectFile = StrippingInfo.ModuleName(objectFile);

                    if (!moduleSizes.ContainsKey(objectFile))
                    {
                        moduleSizes[objectFile] = 0;
                    }

                    moduleSizes[objectFile] += functionSize.Value;

                    moduleAccounted += functionSize.Value;
                }
                if (assemblyArtifacts.ContainsKey(functionSize.Key))
                {
                    var assembly = assemblyArtifacts[functionSize.Key];
                    if (!assemblySizes.ContainsKey(assembly))
                    {
                        assemblySizes[assembly] = 0;
                    }

                    assemblySizes[assembly] += functionSize.Value;
                }
            }

            AddPlatformSpecificCodeOutputModules();

            int unaccounted = totalSize;

            foreach (var moduleSize in moduleSizes)
            {
                if (modules.Contains(moduleSize.Key))
                {
                    unaccounted -= moduleSize.Value;
                }
            }

            moduleSizes["Unaccounted"] = unaccounted;
            AddModule("Unaccounted", false);
            foreach (var moduleSize in moduleSizes)
            {
                AddModuleSize(moduleSize.Key, moduleSize.Value);
            }

            int totalAssemblySize = 0;

            foreach (var assemblySize in assemblySizes)
            {
                RegisterDependency("IL2CPP Generated", assemblySize.Key);
                sizes[assemblySize.Key] = assemblySize.Value;
                totalAssemblySize      += assemblySize.Value;
                SetIcon(assemblySize.Key, "class/DefaultAsset");
            }
            RegisterDependency("IL2CPP Generated", "IL2CPP Unaccounted");
            sizes["IL2CPP Unaccounted"] = moduleSizes["IL2CPP Generated"] - totalAssemblySize;
            SetIcon("IL2CPP Unaccounted", "class/DefaultAsset");

            if (doSourceCodeAnalysis)
            {
                System.Console.WriteLine("Code size per module: ");
                PrintSizesDictionary(moduleSizes);
                System.Console.WriteLine("\n\n");

                System.Console.WriteLine("Code size per source folder: ");
                PrintSizesDictionary(folderSizes);
                System.Console.WriteLine("\n\n");

                System.Console.WriteLine("Code size per object file: ");
                PrintSizesDictionary(objectSizes);
                System.Console.WriteLine("\n\n");

                System.Console.WriteLine("Code size per function: ");
                PrintSizesDictionary(functionSizes);
                System.Console.WriteLine("\n\n");
            }
        }
コード例 #5
0
        public void Analyze()
        {
            bool flag = Unsupported.IsDeveloperMode();
            Dictionary <string, string> symbolArtifacts            = this.GetSymbolArtifacts();
            Dictionary <string, string> moduleArtifacts            = this.GetModuleArtifacts();
            Dictionary <string, string> il2CPPAssemblyMapArtifacts = StrippingInfoWithSizeAnalysis.GetIl2CPPAssemblyMapArtifacts("Temp/StagingArea/Data/il2cppOutput/Symbols/MethodMap.tsv");
            int num = 0;
            Dictionary <string, int> functionSizes = this.GetFunctionSizes();

            foreach (KeyValuePair <string, int> current in functionSizes)
            {
                if (symbolArtifacts.ContainsKey(current.Key))
                {
                    string text = symbolArtifacts[current.Key].Replace('\\', '/');
                    if (flag)
                    {
                        if (!this.objectSizes.ContainsKey(text))
                        {
                            this.objectSizes[text] = 0;
                        }
                        Dictionary <string, int> dictionary;
                        string key;
                        (dictionary = this.objectSizes)[key = text] = dictionary[key] + current.Value;
                    }
                    if (text.LastIndexOf('/') != -1)
                    {
                        string text2 = text.Substring(0, text.LastIndexOf('/'));
                        if (!this.folderSizes.ContainsKey(text2))
                        {
                            this.folderSizes[text2] = 0;
                        }
                        Dictionary <string, int> dictionary;
                        string key2;
                        (dictionary = this.folderSizes)[key2 = text2] = dictionary[key2] + current.Value;
                    }
                }
                if (moduleArtifacts.ContainsKey(current.Key))
                {
                    string text3 = moduleArtifacts[current.Key];
                    text3 = text3.Substring(0, text3.Length - "Module_Dynamic.bc".Length);
                    text3 = StrippingInfo.ModuleName(text3);
                    if (!this.moduleSizes.ContainsKey(text3))
                    {
                        this.moduleSizes[text3] = 0;
                    }
                    Dictionary <string, int> dictionary;
                    string key3;
                    (dictionary = this.moduleSizes)[key3 = text3] = dictionary[key3] + current.Value;
                    num += current.Value;
                }
                if (il2CPPAssemblyMapArtifacts.ContainsKey(current.Key))
                {
                    string text4 = il2CPPAssemblyMapArtifacts[current.Key];
                    if (!this.assemblySizes.ContainsKey(text4))
                    {
                        this.assemblySizes[text4] = 0;
                    }
                    Dictionary <string, int> dictionary;
                    string key4;
                    (dictionary = this.assemblySizes)[key4 = text4] = dictionary[key4] + current.Value;
                }
            }
            this.AddPlatformSpecificCodeOutputModules();
            int num2 = this.totalSize;

            foreach (KeyValuePair <string, int> current2 in this.moduleSizes)
            {
                if (this.modules.Contains(current2.Key))
                {
                    num2 -= current2.Value;
                }
            }
            this.moduleSizes["Unaccounted"] = num2;
            base.AddModule("Unaccounted", false);
            foreach (KeyValuePair <string, int> current3 in this.moduleSizes)
            {
                base.AddModuleSize(current3.Key, current3.Value);
            }
            int num3 = 0;

            foreach (KeyValuePair <string, int> current4 in this.assemblySizes)
            {
                base.RegisterDependency("IL2CPP Generated", current4.Key);
                this.sizes[current4.Key] = current4.Value;
                num3 += current4.Value;
                base.SetIcon(current4.Key, "class/DefaultAsset");
            }
            base.RegisterDependency("IL2CPP Generated", "IL2CPP Unaccounted");
            this.sizes["IL2CPP Unaccounted"] = this.moduleSizes["IL2CPP Generated"] - num3;
            base.SetIcon("IL2CPP Unaccounted", "class/DefaultAsset");
            if (flag)
            {
                Console.WriteLine("Code size per module: ");
                StrippingInfoWithSizeAnalysis.PrintSizesDictionary(this.moduleSizes);
                Console.WriteLine("\n\n");
                Console.WriteLine("Code size per source folder: ");
                StrippingInfoWithSizeAnalysis.PrintSizesDictionary(this.folderSizes);
                Console.WriteLine("\n\n");
                Console.WriteLine("Code size per object file: ");
                StrippingInfoWithSizeAnalysis.PrintSizesDictionary(this.objectSizes);
                Console.WriteLine("\n\n");
                Console.WriteLine("Code size per function: ");
                StrippingInfoWithSizeAnalysis.PrintSizesDictionary(functionSizes);
                Console.WriteLine("\n\n");
            }
        }