-/*\r
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-using System;\r
-using System.Runtime;\r
-using System.Threading.Tasks;\r
-\r
-namespace Tizen.Runtime\r
-{\r
- public class Profiler\r
- {\r
- private static void stop()\r
- {\r
- Console.WriteLine("Stop profile and write collected data");\r
- ProfileOptimization.StartProfile(null);\r
- }\r
-\r
- public static void StopProfileAfterDelay(int sec)\r
- {\r
- Console.WriteLine($"Stop profile after {sec} sec");\r
- Task.Delay(sec * 1000).ContinueWith(_ => stop());\r
- }\r
- }\r
-}\r
+/*
+ * 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());
+ }
+ }
+ }
+}