Discussion
· Feb 15, 2022

IRIS Native API for .NET performance issue

I am surprised with the performance (poor) of Native API for .NET

       Following code (where ^testGlobal,node1 has 50 records) takes 5 seconds to run.  Anyone else think there is room for the improvement? 

    string global = "^testGlobal";
            object[] Subs = new object[1];
            Subs[0] = "node1";

            try
            {
                IRISIterator iter = iris.GetIRISIterator(global, Subs); 
               foreach (var item in iter)
                {        
                    Console.WriteLine((string)(iter.CurrentSubscript));
                }               

            }
            catch (Exception ex)
            {

            }
Discussion (8)1
Log in or sign up to continue

I think we need a bit more info about your data structure and your environment. 

I built the following little program on my mac with .NET 5  and it runs really fast (reported as 0 ms).  The data structure in my example, as you can see, is incredibly simple, so that might be the source of performance differences.  I'm also running on localhost, which could be different on your setup.

 

using System;
using InterSystems.Data.IRISClient;
using InterSystems.Data.IRISClient.ADO;

public class IRISNative
{
    public static void Main(String[] args) 
    {
        try {
            IRISConnection conn = new IRISConnection();
            conn.ConnectionString = "Server=localhost; Port=1972; Namespace=User; Password=...; User ID=...; SharedMemory=false; logfile=./dbnative.log";
            conn.Open();

            IRIS iris = IRIS.CreateIRIS(conn);

            Console.WriteLine("[1. Populating the data]");
            string global = "^testGlobal";
            object[] Subs = new object[1];
            Subs[0] = "node1";

            var watch = new System.Diagnostics.Stopwatch();
            watch.Start();
            for (var i=0; i<50; i++) {
                iris.Set(i, global, Subs[0], "node"+i);
            }
            watch.Stop();
            Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms");

            Console.WriteLine("[2. Querying the data]");
            watch = new System.Diagnostics.Stopwatch();
            watch.Start();
            IRISIterator iter = iris.GetIRISIterator(global, Subs);
            foreach (var item in iter)
            {
                Console.WriteLine((string)(iter.CurrentSubscript));
            }
            watch.Stop();
            Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms");

            iris.Close();
            conn.Close();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
}