diff --git a/dotnet/targets/Xamarin.Shared.Sdk.props b/dotnet/targets/Xamarin.Shared.Sdk.props
index 523bea4d6f07..9527c4b0dfa1 100644
--- a/dotnet/targets/Xamarin.Shared.Sdk.props
+++ b/dotnet/targets/Xamarin.Shared.Sdk.props
@@ -234,6 +234,10 @@
<_BundlerEnvironmentVariables Include="DOTNET_ReadyToRun" Value="0" />
+
+ <_BundlerEnvironmentVariables Include="DEBUG_LAUNCH_TIME" Value="1" />
+
+
<_SdkIsSimulator Condition="'$(RuntimeIdentifier)' != '' And '$(_SdkIsSimulator)' == ''">$(RuntimeIdentifier.Contains('simulator'))
diff --git a/runtime/monotouch-main.m b/runtime/monotouch-main.m
index 791901bd65c6..aba63dead0e1 100644
--- a/runtime/monotouch-main.m
+++ b/runtime/monotouch-main.m
@@ -151,31 +151,35 @@
}
#endif // !defined (CORECLR_RUNTIME)
-#ifdef DEBUG_LAUNCH_TIME
-uint64_t startDate = 0;
-uint64_t date = 0;
-void debug_launch_time_print (const char *msg)
+static uint64_t xamarin_launch_startDate = 0;
+static uint64_t xamarin_launch_date = 0;
+static int xamarin_launch_time_enabled = -1;
+
+void xamarin_launch_time_print (const char *msg)
{
+ if (xamarin_launch_time_enabled == -1) {
+ const char *env = getenv ("DEBUG_LAUNCH_TIME");
+ xamarin_launch_time_enabled = (env != NULL && env[0] == '1') ? 1 : 0;
+ }
+
+ if (!xamarin_launch_time_enabled)
+ return;
+
uint64_t unow;
struct timeval now;
gettimeofday (&now, NULL);
- unow = now.tv_sec * 1000000ULL + now.tv_usec;
+ unow = (uint64_t) now.tv_sec * 1000000ULL + (uint64_t) now.tv_usec;
- if (startDate == 0) {
- startDate = unow;
- date = startDate;
+ if (xamarin_launch_startDate == 0) {
+ xamarin_launch_startDate = unow;
+ xamarin_launch_date = xamarin_launch_startDate;
}
- PRINT ("%s: %llu us Total: %llu us", msg, unow - date, unow - startDate);
+ PRINT ("%s: %llu us Total: %llu us", msg, unow - xamarin_launch_date, unow - xamarin_launch_startDate);
- date = unow;
+ xamarin_launch_date = unow;
}
-#else
-inline void debug_launch_time_print (const char *msg)
-{
-}
-#endif
/*
* This class will listen for memory warnings and when received, force
@@ -256,10 +260,10 @@ - (void) memoryWarning: (NSNotification *) sender
managed_argv [managed_argc++] = "monotouch";
#endif
- DEBUG_LAUNCH_TIME_PRINT ("Main entered");
+ XAMARIN_LAUNCH_TIME_PRINT ("Main entered");
xamarin_setup ();
- DEBUG_LAUNCH_TIME_PRINT ("MonoTouch setup time");
+ XAMARIN_LAUNCH_TIME_PRINT ("MonoTouch setup time");
MonoAssembly *assembly;
GCHandle exception_gchandle = NULL;
@@ -278,7 +282,7 @@ - (void) memoryWarning: (NSNotification *) sender
xamarin_bridge_setup ();
- DEBUG_LAUNCH_TIME_PRINT ("Spin-up time");
+ XAMARIN_LAUNCH_TIME_PRINT ("Spin-up time");
{
/*
@@ -408,7 +412,7 @@ - (void) memoryWarning: (NSNotification *) sender
xamarin_bridge_initialize ();
xamarin_initialize ();
- DEBUG_LAUNCH_TIME_PRINT ("\tmonotouch init time");
+ XAMARIN_LAUNCH_TIME_PRINT ("\tmonotouch init time");
if (xamarin_register_assemblies != NULL)
xamarin_register_assemblies ();
@@ -438,13 +442,13 @@ - (void) memoryWarning: (NSNotification *) sender
(void)exception_gchandle;
#endif // !defined (NATIVEAOT)
- DEBUG_LAUNCH_TIME_PRINT ("\tAssembly register time");
+ XAMARIN_LAUNCH_TIME_PRINT ("\tAssembly register time");
[[[XamarinGCSupport alloc] init] autorelease];
- DEBUG_LAUNCH_TIME_PRINT ("\tGC defer time");
+ XAMARIN_LAUNCH_TIME_PRINT ("\tGC defer time");
- DEBUG_LAUNCH_TIME_PRINT ("Total initialization time");
+ XAMARIN_LAUNCH_TIME_PRINT ("Total initialization time");
int rv = 0;
switch (launch_mode) {
diff --git a/runtime/monovm-bridge.m b/runtime/monovm-bridge.m
index dda287dcfbfb..6013963693da 100644
--- a/runtime/monovm-bridge.m
+++ b/runtime/monovm-bridge.m
@@ -53,11 +53,11 @@
{
if (xamarin_register_modules != NULL)
xamarin_register_modules ();
- DEBUG_LAUNCH_TIME_PRINT ("\tAOT register time");
+ XAMARIN_LAUNCH_TIME_PRINT ("\tAOT register time");
#ifdef DEBUG
monotouch_start_debugging ();
- DEBUG_LAUNCH_TIME_PRINT ("\tDebug init time");
+ XAMARIN_LAUNCH_TIME_PRINT ("\tDebug init time");
#endif
if (xamarin_init_mono_debug)
@@ -68,7 +68,7 @@
#ifdef DEBUG
monotouch_start_profiling ();
- DEBUG_LAUNCH_TIME_PRINT ("\tProfiler config time");
+ XAMARIN_LAUNCH_TIME_PRINT ("\tProfiler config time");
#endif
mono_set_signal_chaining (TRUE);
@@ -82,7 +82,7 @@
This is wasteful, but there's no way to manipulate the preload hook list except by adding to it.
*/
mono_install_assembly_preload_hook (xamarin_assembly_preload_hook, NULL);
- DEBUG_LAUNCH_TIME_PRINT ("\tJIT init time");
+ XAMARIN_LAUNCH_TIME_PRINT ("\tJIT init time");
}
void
diff --git a/runtime/runtime-internal.h b/runtime/runtime-internal.h
index c260a900c251..f35c9995ce78 100644
--- a/runtime/runtime-internal.h
+++ b/runtime/runtime-internal.h
@@ -16,14 +16,9 @@
#define PRINT(...) do { xamarin_printf (__VA_ARGS__); } while (0);
#define LOG(...) do { if (xamarin_log_level > 0) xamarin_printf (__VA_ARGS__); } while (0);
-// #define DEBUG_LAUNCH_TIME
-
-#ifdef DEBUG_LAUNCH_TIME
-#define DEBUG_LAUNCH_TIME_PRINT(msg) \
- debug_launch_time_print (msg);
-#else
-#define DEBUG_LAUNCH_TIME_PRINT(...)
-#endif
+void xamarin_launch_time_print (const char *msg);
+#define XAMARIN_LAUNCH_TIME_PRINT(msg) \
+ xamarin_launch_time_print (msg);
// Uncomment the TRACK_MONOOBJECTS define to show a summary at process exit of
// the MonoObjects that were created, and if any were not freed. If there are
diff --git a/tests/dotnet/UnitTests/expected/iOS-MonoVM-interpreter-size.txt b/tests/dotnet/UnitTests/expected/iOS-MonoVM-interpreter-size.txt
index ff563d529e80..bec783451d9f 100644
--- a/tests/dotnet/UnitTests/expected/iOS-MonoVM-interpreter-size.txt
+++ b/tests/dotnet/UnitTests/expected/iOS-MonoVM-interpreter-size.txt
@@ -1,12 +1,12 @@
-AppBundleSize: 3,611,961 bytes (3,527.3 KB = 3.4 MB)
+AppBundleSize: 3,631,541 bytes (3,546.4 KB = 3.5 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
_CodeSignature/CodeResources: 3,997 bytes (3.9 KB = 0.0 MB)
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
-Info.plist: 1,167 bytes (1.1 KB = 0.0 MB)
-Microsoft.iOS.dll: 150,528 bytes (147.0 KB = 0.1 MB)
+Info.plist: 1,147 bytes (1.1 KB = 0.0 MB)
+Microsoft.iOS.dll: 153,088 bytes (149.5 KB = 0.1 MB)
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin: 1,405 bytes (1.4 KB = 0.0 MB)
-SizeTestApp: 2,388,080 bytes (2,332.1 KB = 2.3 MB)
+SizeTestApp: 2,405,120 bytes (2,348.8 KB = 2.3 MB)
SizeTestApp.dll: 7,680 bytes (7.5 KB = 0.0 MB)
System.Private.CoreLib.aotdata.arm64: 41,368 bytes (40.4 KB = 0.0 MB)
System.Private.CoreLib.dll: 1,004,032 bytes (980.5 KB = 1.0 MB)