Похожие чаты

Someone knows how to calculate writing speeds? I need to

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

23 ответов

20 просмотров

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

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

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

как правильно удалить сддм? прописал в etc/portage.use/plasma-meta -sddm , но при обновлении юзов мне предлагает поставить lightdm (ещё лучше 😡), добавил туда - display-manage...
REDis
25
#include <stdio.h> #include <stdlib.h> #include <time.h> void mass_first_generate(int mass[5][7]) {     for (int N = 0; N < 5; N++) {         for (int A = 0; A < 7; A++) {   ...
Чувак
6
Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
https://www.linkedin.com/posts/ugama-benedicta-kelechi-codergirl-103041300_mobiledevelopment-fluttertraining-handsonlearning-activity-7263445699227254784-IdHB?utm_source=share...
CoderGirl
16
like, question: int b = 99999; is this valid and predictable C?
Ludovic 'Archivist' Lagouardette
15
Помогите пожалуйста. Делаю систему плагинов. Проблема сейчас в такая: плагины загружаются в основном потоке. FLibHandle := SafeLoadLibrary(FFileName) Но нужно еще выполнить фу...
Илья 🤣
10
VIP-397 BNBx Oracle implementation upgrade Summary This proposal, if approved, will upgrade the implementation of the BNBx Oracle contract on Venus from version 1 (V1) to v...
Venus Announcements
2
Ну вот просто даже давайте вот как. Какой нибудь конкретный кейс, можете в пример привести, где бч работает и приносит прикладную пользу, а не просто что бы было? Не крипту.
Alexander Andreev
22
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
Карта сайта