0

I am using getaddrinfo() API to resolve DNS queries in a cross platform C++ app. I need to know the time cost of getaddrinfo() in different platforms? Can anyone help me on this?

user207421
  • 305,947
  • 44
  • 307
  • 483
Naseef Chowdhury
  • 2,357
  • 3
  • 28
  • 52
  • 1
    It depends on the address, how many levels deep the delegation hierarchy is, the network latency to all the nameservers, the speed of the servers, whether any of the intermediate data is cached, etc. There's no simple answer to this. – Barmar Jun 19 '14 at 02:39
  • 1
    You're misusing terminology. 'Time complexity' is a term from analysis of algorithms and the result is expressed in 'Big-O' notation. All you're asking about is *performance,* measured in time units. – user207421 Jun 19 '14 at 02:54
  • Yes, I am asking about its performance. – Naseef Chowdhury Jun 19 '14 at 02:57
  • 1
    I suppose your question is similar to a question like "how long does a ping take?", which is family of "how long is a string?". The query itself is quick. Processing the reply is quick too. The in-between part can be time consuming. – Deleted User Jun 19 '14 at 08:59
  • @Bushmills how much time consuming? Could you please elaborate with an example? – Naseef Chowdhury Jun 19 '14 at 09:48
  • 1
    based on current technology: longer than 0.1 nanoseconds, but less than an hour. – Deleted User Jun 19 '14 at 09:56

1 Answers1

3

This function does not have algorithmic complexity because it is not doing any complex computation inside. The best you should take measurements on the systems/platforms that you are using and base your expectations on this.

The result will drastically vary depending on the network that you have. Imagine system that has a slow dial-up connection. Its speed will not have anything in common with fast LAN and DNS server sitting on the same LAN.

Kirill Kobelev
  • 10,252
  • 6
  • 30
  • 51
  • 1
    That's right. Actually I wanted to know average time consumptions of this function. – Naseef Chowdhury Jun 19 '14 at 02:47
  • Make some measurements yourself. This is the best what you can do. There is no public info on this. – Kirill Kobelev Jun 19 '14 at 02:49
  • 1
    The problem is that I don't have all the platform support right now. I need to design the code and currently I can perform the test in Linux and Windows. But If I could know the time complexity of this function it could have been better for me. – Naseef Chowdhury Jun 19 '14 at 02:55