Created
August 1, 2016 18:50
-
-
Save jonpryor/b4f3589b08b7afeb7809a5b454e1126e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -u MainActivity.cs.jonp-orig MainActivity.cs | |
--- MainActivity.cs.jonp-orig 2016-07-06 17:11:28.000000000 -0400 | |
+++ MainActivity.cs 2016-08-01 14:45:49.000000000 -0400 | |
@@ -3,7 +3,10 @@ | |
using Android.OS; | |
using Android.Runtime; | |
+using Java.Interop; | |
+ | |
using System; | |
+using System.Diagnostics; | |
using System.Threading; | |
namespace JNICrash | |
@@ -31,6 +34,7 @@ | |
// Get off the main thread. | |
Thread thread = new Thread(() => | |
{ | |
+ var time = Stopwatch.StartNew(); | |
// Perform the test 1024 times (greater than the | |
// size of the local reference table). | |
for (int i = 0; i < 1024; i++) | |
@@ -40,6 +44,8 @@ | |
// The source for this method can be found in | |
// libdemo/src/demo_DemoLibrary.c. | |
IntPtr outputPtr = DemoLibrary.Java_demo_DemoLibrary_test(JNIEnv.Handle, IntPtr.Zero); | |
+ JniEnvironment.References.CreatedReference ( | |
+ new JniObjectReference (outputPtr, JniObjectReferenceType.Local)); | |
// Get the result of the method as a C# byte[]. | |
// This worked in Xamarin.Android 5, but now floods the logs | |
@@ -52,6 +58,8 @@ | |
// Update our counter. | |
Console.WriteLine("Called test() method {0} times (output length: {1} bytes).", count++, output.Length); | |
} | |
+ time.Stop(); | |
+ Console.WriteLine("# jonp: Elapsed time: {0}ms", time.ElapsedMilliseconds); | |
}) | |
{ | |
IsBackground = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment