Похожие чаты

Someone knows how to calculate writing speeds? I need to

calculate the amount of bytes written by consecutives write() calls in a second

23 ответов

23 просмотра

Idk exactly but i think time.h's time() returns a long representing milli secs from 1/1/1970 (like its java System class equ) you can simply store it in a var and then substract them from each other after invoking your write() calls

Nader Jafari
Idk exactly but i think time.h's time() returns a ...

Well you edited your question to do this each second. You can do this in a new thread and sleep()

Mattia- Автор вопроса
Nader Jafari
Well you edited your question to do this each seco...

To do so i believe i'd need to add a pthread_lock on the variable of the total bytes written, and considering the sleep not being precise, the lock adding delay for the next writing cycle, i think the calculations would result very wrong. Maybe not all the calculations but probably more than i'd love

Writing speeds of what? What do you want to measure? Could you please elaborate?

Mattia- Автор вопроса
Cengizhan Pasaoglu
Writing speeds of what? What do you want to measur...

1. Bytes written in a system call to the write(fd,buf,count) function 2. Bytes per second 3. It is in C, linux, nothing else

Mattia
1. Bytes written in a system call to the write(fd,...

Use std::chrono to measure time of writing 1MB of bytes

Mattia
1. Bytes written in a system call to the write(fd,...

Stıll depends on what kınd of Kernel you have, and what will be jitters at that time. Because, if you don't have real-time patched Kernel on the system. you cannot know that how much you need for writing (you have to collect a few measurement and divide by number of trials) even though some jitters will affect your measurement like SMIs, timers etc.

Cengizhan Pasaoglu
Stıll depends on what kınd of Kernel you have, and...

You shouldn't guess or ensure how many bytes you can write per second because of these problems.

Mattia- Автор вопроса
Cengizhan Pasaoglu
Stıll depends on what kınd of Kernel you have, and...

Linux raspberrypi 5.4.72-v7l+ #1356 SMP Thu Oct 22 13:57:51 BST 2020 armv7l GNU/Linux

Mattia
Linux raspberrypi 5.4.72-v7l+ #1356 SMP Thu Oct 22...

I was saying that it depends on many different things. Measurement will be valid only on your machine, and also maybe how many bytes you will write etc, caching, page faults, timers etc. Many parameter can affect on your result.

Mattia- Автор вопроса
Cengizhan Pasaoglu
I was saying that it depends on many different thi...

I don't need to use the measurements out of my code, so the results can be considered valid(?) The bytes i write are returned by write(), so it is a precise measure

Mattia
I don't need to use the measurements out of my cod...

How do you know that when you call write() function, other threads or interrupts on the kernel whether block or not your write() function?

Mattia- Автор вопроса
Aakash Saini
👆

I've tried the code, but i've got to compare it to more precise timing options

Mattia
I've tried the code, but i've got to compare it to...

More precise like? It’s very precise to function call within start/stop; you just need to fix buffer to bytes.. little code

Mattia- Автор вопроса
Cengizhan Pasaoglu
How do you know that when you call write() functio...

Hmmm in that case -1 is returned, which is the case in which i have to re-write and don't consider the write output for measurements, making them temporarily non-usable

Mattia
Hmmm in that case -1 is returned, which is the cas...

Do you have information about Linux Kernel or Operating systems at all?

Mattia
I've tried the code, but i've got to compare it to...

You can google it too! Here is sample. —> https://mobile.happycodings.com/c//beginners-lab-assignments/code47.html

Mattia- Автор вопроса
Aakash Saini
More precise like? It’s very precise to function c...

I think that your code makes good measurements only in CPUs with stable and non-adaptable clocks , which isn't always true

Mattia
Kind of, why ask?

What I was trying to say, you cannot know precisely in user-space how many bytes you can write per second, or you cannot expect to see the same values for each second.

Mattia- Автор вопроса
Cengizhan Pasaoglu
What I was trying to say, you cannot know precisel...

I absolutely do not expect that always the same values will present. I have not gone into precise details in order to not expand on other topics, but the file descriptor is actually a socket. I am making uploads with that write function

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта