Any different between relative and absolute addressing in performance?

Hi Friends
in case we have just one main collection with one object ( bean in addressing manual ) and one sprite on it, is there any difference in performance between these two kind of addressing:

relative:
msg.post("#body", "disable")
absolute url:
msg.post("main:/bean#body", "disable)

is there any difference in different kind of addressing in general?

3 hours later edit:
i did message chaining like that one on defold manual, in both relative and absolute addressing i got 190 messages between each updates, so i think there is not any difference but i’m interested if someone else gives more info about it.

1 Like

I haven’t tested actually sending messages, but msg.url() definitely takes a different amount of time depending on what you give it, and I assume msg.post() has to evaluate the address the same way.

A quick test, calling msg.url in a loop with a few hundred thousand iterations:

‘URL object’ took 206.01273 ms
‘No address’ took 395.02144 ms
‘String “.”’ took 423.02513 ms
‘String “#”’ took 396.02280 ms
‘String relative address’ took 717.04102 ms
‘String absolute address’ took 361.02104 ms

For an object that I will use repeatedly, I get its URL once on init and store it in “self” to use later.

3 Likes

Do you mean local url = msg.url([socket],[path],[fragment]) by URL object?

1 Like

Yes I wanted to know about message.post() to know which way is faster to communicate between objects and components. cool results about msg.url(), maybe these times help me and others later :+1:

Yup. Any valid result of msg.url.

:+1:
Don’t remember where, but I read somewhere at the docs; everything else (id, hash, string) are converted to the msg.url internally.

2 Likes

Let’s have a look!

msg.post()

Implementation: defold/engine/script/src/script_msg.cpp at 1.2.169 ¡ defold/defold ¡ GitHub

Relevant lines of code to resolve the URL:

msg.url()

Implementation: defold/engine/script/src/script_msg.cpp at 1.2.169 ¡ defold/defold ¡ GitHub

There are multiple code paths here, depending on the data you pass it. If you pass a single argument the same ResolveURL() function is called as when doing a msg.post(). Implementation: defold/engine/script/src/script_msg.cpp at 1.2.169 ¡ defold/defold ¡ GitHub

6 Likes