/* * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.IO; using System.Runtime; using System.Threading.Tasks; namespace Tizen.Runtime { public class Profiler { const string profilePath = "/home/owner/data/.__tizen_candidate_profile_data"; private static void stop() { Console.WriteLine("Stop profile and write collected data"); ProfileOptimization.StartProfile(null); } public static void StopProfileAfterDelay(int sec) { Console.WriteLine($"Stop profile after {sec} sec"); Task.Delay(sec * 1000).ContinueWith(_ => stop()); } public static void SetCandidateProcessProfile() { try { if (File.Exists(profilePath)) { Environment.SetEnvironmentVariable("COMPlus_MultiCoreJitNoProfileGather", "1"); Environment.SetEnvironmentVariable("COMPlus_MultiCoreJitMinNumCpus", "1"); ProfileOptimization.SetProfileRoot(""); ProfileOptimization.StartProfile(profilePath); Console.WriteLine("Completed loading of profile data to the candidate process"); } } catch (Exception e) { Console.WriteLine(e.ToString()); } } } }