Похожие чаты

Is the speed of c function only depends on number

of clocks pulses?

4 ответов

12 просмотров

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.

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

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

Какой-то там пердун в 90-х решил, что есть какая-то разная типизация. Кого вообще это волнует?
КТ315
49
Hi. Do we have a raid bot? Why nobody doing raids on X? Even RH mentioned this and nobody paying attention...whats the channel for hex memes? If mods cant run raids just insta...
H
31
Подскажите, а есть vault lite или ченить такое?) А то нужен вольт для похода в вольт, но весит он ~500 мб) как-то многовато для парочки запросов ))
Alexandr Orloff
17
блеать, почему так?? где в роутере это исправляется?
Арсен Маньяков 🇦🇲
16
void terminal_scroll() { memmove(terminal_buffer, terminal_buffer + VGA_WIDTH, buffer_size - VGA_WIDTH); memset(terminal_buffer + buffer_size - VGA_WIDTH, 0, VGA_WIDTH); ...
Егор
47
🌊 Ocean Nodes Dashboard Update 🚀 Hey, Oceaners! First off, a massive round of applause 👏to all of you for the amazing engagement since we launched Ocean Nodes. In just a few ...
KreigDK | Never DM first🌊
3
Всем привет! Подскажите, пожалуйста, в чем ошибка? Настраиваю подключение к MySQL. Либы лежат рядом с exe. Все как по "учебнику"
Евгений
16
А можете как-то проверить меня по знаниям по ассемблеру?
A A
132
Здравствуйте! У меня появилась возможность купить книгу "Изучай Haskell во имя добра!". Но я где-то слышал, что эта книга устарела. Насколько это правда??
E
22
люди, которые используют flameshot, к вам вопрос. Можно-ли поставить хоткей на создание скриншота? В программе есть отдел "горячие клавиши", но там все для редактирования, скр...
ThunDer104
11
Карта сайта