<commit_before>﻿using MonoMod.RuntimeDetour;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace MonoMod.UnitTest {
    public class TieredCompilationTests {

        private static bool TargetHit = false;

        //
        // So, it turns out that methods are only eligible for recompilation if they are not in an assembly
        //   marked debuggable. In other words, this test will only ever fail when this assembly is built
        //   in release mode. In debug mode, it will never fail.
        //

#if DEBUG
        [Fact(Skip = "This test will ONLY fail in Release builds")]
#else
        [Fact]
#endif
        public void WithTieredCompilation() {
            Console.ReadLine();

            using (new Detour(() => From(), () => To())) {
                TestFrom();
            }
        }

        private static void TestFrom() {
            Stopwatch sw = new Stopwatch();
            for (int loop = 0; loop < 5; loop++) {
                // first we make sure From qualifies for recomp
                for (int i = 0; i < 1000; i++) {
                    TargetHit = false;
                    From();<commit_msg>Hid debug wait behind environment variable<commit_after>﻿using MonoMod.RuntimeDetour;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace MonoMod.UnitTest {
    public class TieredCompilationTests {

        private static bool TargetHit = false;

        //
        // So, it turns out that methods are only eligible for recompilation if they are not in an assembly
        //   marked debuggable. In other words, this test will only ever fail when this assembly is built
        //   in release mode. In debug mode, it will never fail.
        //

#if DEBUG
        [Fact(Skip = "This test will ONLY fail in Release builds")]
#else
        [Fact]
#endif
        public void WithTieredCompilation() {
            if (Environment.GetEnvironmentVariable("MM_TEST_DEBUG_TIERED_COMP") != null) {
                Console.WriteLine("Attach the debugger then press enter");
                Console.ReadLine();
            }

            using (new Detour(() => From(), () => To())) {
                TestFrom();
            }
        }

        private static void TestFrom() {
            Stopwatch sw = new Stopwatch();
            for (int loop = 0; loop < 5; loop++) {
                // first we make sure From qualifies for recomp
                for (int i = 0; i < 1000; i++) {
                    TargetHit = false;
                    From();
{'fraction_non_alphanumeric': 0.0904679376083189, 'fraction_numerical': 0.004852686308492201, 'mean_word_length': 2.076759061833689, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7147115', 'n_tokens_mistral': 765, 'n_tokens_neox': 736, 'n_words': 279}