Похожие чаты

Someone knows how to calculate writing speeds? I need to

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

23 ответов

12 просмотров

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

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

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

@LGCYMan @JustinKKW Q/A List 1. this part confuses me on #8: "From there, a bridge between erc20 LGXY and erc20 LGXY will be out once that swap is closed." does this mean ...
Sig | LGCY | BattleVerse L1 | BitWin
1
Anyone here suffers from unexplained aural migraines, who would be up for talking for a bit? Doesn't *have* to be aural, but I am not asking about headaches, I mean actual mi...
Martin Rys
55
Привет, нужен совет старших товарищей. Есть глобальная переменная var DefaultDataFolder:string; инициализируем DefaultDataFolder:='a:\_OUT\'; есть примитивная процедур...
Max Otto
11
A couple thoughts from a random internet stranger: 1. If you want this project to gain traction you cannot keep being negative. If I just came here after finding out about Kd...
Eric Wild
46
We heading to 1.1$ 🤔?
CryptoBo$$
35
Вопрос. Теоретический. Есть список команд. Команды отправляю в обработку некой функции, по очереди. Разные команды могут давать разные результаты после обработки. В зависимос...
Serjone
7
Agreed. And on a lighter note, I just love the idea of earning $FunToken while having fun. It’s like getting paid to do what we love. Who wouldn’t want that? 😄
SpaceGemz
13
Сonst magicTgHTML = (text, entities) => { let processedText = text; let offsetShift = 0; entities.forEach(entity => { const { offset, length, type, url, ...
Андрей
1
I can answer questions or just drop the q/a?
Justin | LGCY |
9
But is may still valid as a goal ?
oneBlock!³
10
Карта сайта