Похожие чаты

Is the speed of c function only depends on number

of clocks pulses?

4 ответов

16 просмотров

This is a weird statement to make. What do you mean speed of a function? Are you referring to the cycles taken by the call instruction?

Saeed-Aal boniat Автор вопроса
Manav | avoid unnecessary messaging me
This is a weird statement to make. What do you me...

I have two implementation that do the same thing How can I measure the speed of them to know which one is faster? Is there any unit or something to do that?

Saeed Aal boniat
I have two implementation that do the same thing H...

The one with better algorithmic complexity will be faster when the input size increases. For algorithms with the same complexity you can use a benchmarking library to determine which is faster. This will be a small constant factor which might vary from compiler to compiler and architecture to architecture. Generally these sort of optimizations are considered to be premature and tend to be done only when you need to squeeze out every ounce of performance and is typically done in OS code and Game engines and some math libraries. For the rest of the code out there, you generally don't need to do this.

Saeed Aal boniat
I have two implementation that do the same thing H...

+1 to Madhu and Manav What you are referring to is benchmarking. There are a lot of caveats in benchmarking as a lot of stuff can affect the results (different input data, processor architecture, data layout, other processes running, etc.). You can find some mentioned here: https://m.youtube.com/watch?v=r-TLSBdHe1A If your function is disconnected from other code, then as the first approximation I would suggest to use quickbench https://quick-bench.com/ (Note that there are caveats with it as well, you need to carefully choose what you don't want to optimize to measure the correct thing). If your function is part of the system and you want to measure things together, it can be more tricky depending on how often it is called and how much time it takes.

Похожие вопросы

Обсуждают сегодня

Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
For all those that keep asking why no pump? why this ? and why that...? Please close ur ewt chart and open 2 others - TOTAL (total mc) and BTC.D (btc dominance). Maybe BTC a...
Inn3r_G
19
"Since pnut can flip FTM easily, I'm swapping my FTM to pnut and hoping for a easy x5-x10" Perfect recipe for disaster. NFA but chances are, you'll end up as exit liquidity ...
C. A.
7
AMD status update? No longer in the plan but something might be around the corner later on Chinese partner? No longer in the plan. This market does not seem to be the top ...
Ben
6
I get confused when people talk about the ‘bull market’ and the ‘next bull market’ as if anyone really has a clue what’s really going on in the world. First of all - there i...
Shah
1
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Добрый день, подскажите, пожалуйста, по проблеме. Сегодня на работе утром обнаружилось что по рдп подключиться не получается к серверу 2022. В серверную зашел - на системно...
srv
19
И никого не интересует какие пакеты кто использует. ((% Заходишь на сайт симфони и видишь поддержку Украины - по законам РФ это ж экстремизм. Только никто не отказывается от с...
Am Ambrion
11
Мне вот любопытно. Уже сколько времени имею соблазн купить макбук, ибо подозреваю что очень уж удобен будет в связке с другой техникой от эпл которая у меня есть, да и сам по ...
Not Yeromin
9
лучше скажите, причём тут паскаль?
Alexey Kulakov
36
Карта сайта