1
Vote

Potential performance problem with QueryNames

description

The following code executes ~ 13 seconds (1 seconds using WsMan automation)
 
static void ShowMBeanServerInfo()
{
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
var uri = new Uri("http://localhost:10003/"); using (INetMXConnector connector = new Jsr262Connector(uri, null, 100)) { connector.Connect(null);
IMBeanServerConnection remoteServer = connector.MBeanServerConnection;

// get the default domain
Console.WriteLine("Default domain = {0}", connection.GetDefaultDomain());

// get all the domains
Console.WriteLine("Querying all domains..");
foreach (var domain in connection.GetDomains())
Console.WriteLine("- domain = {0}", domain);

Console.WriteLine("Querying all ObjectNames..");
 
List<ObjectName> objectNameCache = new List<ObjectName>();

var watch = Stopwatch.StartNew();
 
foreach (var name in objectNames)
{
objectName = name;
objectNameCache.Add(objectName);
//Console.WriteLine("ObjectName=" + objectName");
}

Console.WriteLine("Query returned {0} ObjectNames and took {1} ..",
objectNameCache.Count,
watch.Elapsed
);
}
}

comments