Example #1
0
        static void RunBenchmark(Plugin plugin)
        {
            object ret;
            var iterations = 100000;
            var t = DateTime.Now;
            for (var i = 0; i < iterations; i++)
            {
                plugin.DirectCallHook("OnMy", out ret, new[] { "test" });
                plugin.DirectCallHook("OnMy2", out ret, new[] { "test2" });
                plugin.DirectCallHook("OnMy3", out ret, new[] { "test3" });
                plugin.DirectCallHook("OnMy4", out ret, new[] { "test4" });
                plugin.DirectCallHook("OnMy5", out ret, new[] { "test5" });
                plugin.DirectCallHook("OnMy6", out ret, new[] { "test6" });
                plugin.DirectCallHook("OnMy7", out ret, new[] { "test7" });
                plugin.DirectCallHook("OnMy8", out ret, new[] { "test8" });
                plugin.DirectCallHook("OnMy9", out ret, new[] { "test9" });
                plugin.DirectCallHook("OnYour", out ret, new[] { "test0" });
            }
            Puts($"Calling {10 * iterations} hooks directly took {DateTime.Now - t}");

            t = DateTime.Now;
            for (var i = 0; i < iterations; i++)
            {
                plugin.CallHook("OnMy", out ret, new[] { "test" });
                plugin.CallHook("OnMy2", out ret, new[] { "test2" });
                plugin.CallHook("OnMy3", out ret, new[] { "test3" });
                plugin.CallHook("OnMy4", out ret, new[] { "test4" });
                plugin.CallHook("OnMy5", out ret, new[] { "test5" });
                plugin.CallHook("OnMy6", out ret, new[] { "test6" });
                plugin.CallHook("OnMy7", out ret, new[] { "test7" });
                plugin.CallHook("OnMy8", out ret, new[] { "test8" });
                plugin.CallHook("OnMy9", out ret, new[] { "test9" });
                plugin.CallHook("OnYour", out ret, new[] { "test0" });
            }
            Puts($"Calling {10 * iterations} hooks with Invoke took {DateTime.Now - t}");
        }
Example #2
0
 public PluginTimers(Plugin plugin)
 {
     this.plugin = plugin;
 }
Example #3
0
 /// <summary>
 /// Called when the plugin manager is unloading a plugin that was loaded by this plugin loader
 /// </summary>
 /// <param name="plugin_base"></param>
 public override void Unloading(Plugin plugin_base)
 {
     var plugin = plugin_base as CSharpPlugin;
     LoadedPlugins.Remove(plugin.Name);
     // Unload plugins which require this plugin first
     foreach (var compilable_plugin in plugins.Values)
     {
         if (compilable_plugin.Requires.Contains(plugin.Name))
             Interface.Oxide.UnloadPlugin(compilable_plugin.Name);
     }
 }
Example #4
0
 void base_OnPluginUnloaded(Plugin plugin)
 {
     FieldInfo field;
     if (pluginReferenceFields.TryGetValue(plugin.Name, out field)) field.SetValue(this, null);
 }
Example #5
0
 public PluginFieldInfo(Plugin plugin, FieldInfo field)
 {
     Plugin = plugin;
     Field = field;
     FieldType = field.FieldType;
     GenericArguments = FieldType.GetGenericArguments();
 }
Example #6
0
 public PluginFieldInfo(Plugin plugin, FieldInfo field)
 {
     this.Plugin = plugin;
     this.Field = field;
     this.FieldType = field.FieldType;
     this.GenericArguments = FieldType.GetGenericArguments();
 }
Example #7
0
 /// <summary>
 /// Called when the plugin manager is unloading a plugin that was loaded by this plugin loader
 /// </summary>
 /// <param name="plugin_base"></param>
 public override void Unloading(Plugin plugin_base)
 {
     var plugin = plugin_base as CSharpPlugin;
     LoadedPlugins.Remove(plugin.Name);
 }