John Lokanis Posted November 6, 2015 Report Share Posted November 6, 2015 Here is a fun fact I just discovered: If you want to get the host name of your machine in LabVIEW, there is a function for that: If you want to get the host name using .NET, then you can call the method System.Net.DNS.GetHostName using an invoke node: https://msdn.microsoft.com/en-us/library/system.net.dns.gethostname(v=vs.100).aspx Now the fun part: If you call each of these functions on a Window7 OS they execute fairly quickly: LabVIEW Method: 0.000289767 seconds consistently. .NET Method: 0.182981 first call, 0.000417647 seconds subsequent calls (must be a cache) Next, try the same thing on a Windows Server 2012R2 OS: LabVIEW Method: 4.53384 seconds (WTF LabVIEW???) .NET Method: 0.187395 first call, 0.000350523 seconds subsequent calls (again, must be a cache) So, let's say you are using the machine name at a unique identifier to manage a networked messaging architecture. And as a result, you are often getting the machine name to tag a message you are sending with the sender's 'name'. And you decide to run you system on Windows Server 2012R2 OS. It will *work* but your performace will be down the tubes... Any ideas on what could possibly be causing this? I know I could come up with my own cache of the host name in my code and then access it via FGV or something simular, but that is no excuse for this dismal performance. FWIW, there is yet another way to do this: https://msdn.microsoft.com/en-us/library/system.environment.machinename.aspx execution time: 7.91631E-5 seconds on Both OSes. This leads me to the fact that a lot of the advice out there on this topic may need updating. http://digital.ni.com/public.nsf/allkb/4B3877DB13370AA586257542003945A9 https://decibel.ni.com/content/docs/DOC-3917 http://forums.ni.com/t5/LabVIEW/Get-Computer-Name/td-p/101433 -John 1 Quote Link to comment
Rolf Kalbermatter Posted November 7, 2015 Report Share Posted November 7, 2015 Here is a fun fact I just discovered: If you want to get the host name of your machine in LabVIEW, there is a function for that: get machine name snip.png If you want to get the host name using .NET, then you can call the method System.Net.DNS.GetHostName using an invoke node: get machine name dotNET snip.png https://msdn.microsoft.com/en-us/library/system.net.dns.gethostname(v=vs.100).aspx Now the fun part: If you call each of these functions on a Window7 OS they execute fairly quickly: LabVIEW Method: 0.000289767 seconds consistently. .NET Method: 0.182981 first call, 0.000417647 seconds subsequent calls (must be a cache) Next, try the same thing on a Windows Server 2012R2 OS: LabVIEW Method: 4.53384 seconds (WTF LabVIEW???) .NET Method: 0.187395 first call, 0.000350523 seconds subsequent calls (again, must be a cache) So, let's say you are using the machine name at a unique identifier to manage a networked messaging architecture. And as a result, you are often getting the machine name to tag a message you are sending with the sender's 'name'. And you decide to run you system on Windows Server 2012R2 OS. It will *work* but your performace will be down the tubes... Any ideas on what could possibly be causing this? I know I could come up with my own cache of the host name in my code and then access it via FGV or something simular, but that is no excuse for this dismal performance. FWIW, there is yet another way to do this: get machine name mscorlib snip.png https://msdn.microsoft.com/en-us/library/system.environment.machinename.aspx execution time: 7.91631E-5 seconds on Both OSes. This leads me to the fact that a lot of the advice out there on this topic may need updating. http://digital.ni.com/public.nsf/allkb/4B3877DB13370AA586257542003945A9 https://decibel.ni.com/content/docs/DOC-3917 http://forums.ni.com/t5/LabVIEW/Get-Computer-Name/td-p/101433 -John I would guess a configuration issue in the network stack. The LabVIEW function calls into WinSock which then will query the DNS resolver to return the TCP/IP network name. The WinSock provider works with internal timeouts when quering other services such as the DNS resolver. There is no easy way to influence those timeouts from a WinSock client. The .Net function most likely calls GetComputerNameEx() which queries some information in the registry that is usually updated with some largish interval in the background. Quote Link to comment
John Lokanis Posted November 9, 2015 Author Report Share Posted November 9, 2015 Thanks for the info. I suspected something like this. I finally got the IT guys to dig into this and they found an issue with the NIC configuration and drivers on the VM. (This VM is dual homed across our corporate network and a private testing network in my lab). Seems that LabVIEW is much more susceptible to issues like this than other languages. In the end, I changed my code to use the .NET call to the Environment.MachineName property. And I took the further step to wrap that in a FGV that sets the value on first call and then returns it on all subsequent calls. This will protect me from any future issues that introduce a delay when getting this data. Quote Link to comment
Jonathan Lindsey Posted October 28, 2021 Report Share Posted October 28, 2021 I can't get the VI snippet to work and can't figure out how to create the property node from scratch. Could someone post a VI attachment of the above code please? (A link to learning about how to create a property node like this wouldn't hurt either.) Quote Link to comment
FantasticNerd Posted October 28, 2021 Report Share Posted October 28, 2021 5 hours ago, Jonathan Lindsey said: I can't get the VI snippet to work and can't figure out how to create the property node from scratch. Could someone post a VI attachment of the above code please? (A link to learning about how to create a property node like this wouldn't hurt either.) Maybe this will help you creating a proberty note: Property Node - LabVIEW 2018 Help - National Instruments (ni.com) Quote Link to comment
LogMAN Posted October 28, 2021 Report Share Posted October 28, 2021 9 hours ago, Jonathan Lindsey said: I can't get the VI snippet to work and can't figure out how to create the property node from scratch. Could someone post a VI attachment of the above code please? (A link to learning about how to create a property node like this wouldn't hurt either.) You can use the shortcut menu on a property node to select the .NET class. The one you are looking for is in the mscorlib assembly. System.Environment.vi 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.