Calculate the MB/s from know milliseconds and bytes

Just starting out? Need help? Post your questions and find answers here.
Simo_na
Enthusiast
Enthusiast
Posts: 177
Joined: Sun Mar 03, 2013 9:01 am

Calculate the MB/s from know milliseconds and bytes

Post by Simo_na »

Hi
I have written 2097152 bytes to my drive and it took 635 milliseconds.
How can I calculate the MB/s with Purebasic?
I think:
bytes = 2097152

convert bytes to bit
bit = 2097152 * 8 = 16777216

milliseconds = 635

for 1 milliseconds I have written:
16777216 / 635 = 26.420 bit

now i convert all to MB/s
so:
26.420 / 1024 / 8 = 0.003 MB/s

the logic/formula I have written here is the correct one ?

Thank you
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Calculate the MB/s from know milliseconds and bytes

Post by infratec »

Think a bit ...

2097152 bytes are nearly 2MB

If you wrote this in 0.6 seconds, the MB/s must nearly the double value and not 0.00X

Code: Select all

bytes.i = 2097152
ms.i = 653
MBs.d = bytes / ms * 1000 / 1024 / 1024

;MBs.d = bytes / ms / 1048.576

Debug MBs
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Calculate the MB/s from know milliseconds and bytes

Post by STARGÅTE »

Please consider, also 1 MB (mega byte) is a SI unit and exactly 1,000,000. The other unit is 1 MiB (mebi byte), which is 1024*1024.
Binary prefix

Unfortunately, this is also done incorrectly by Windows, which means a 3 TB hard drive is in windows wrongly 2.72 TB

Code: Select all

bytes.i = 2097152
ms.i = 653
MBs.d = bytes / (ms*1000)

Debug StrD(MBs, 3) + " MB/s"
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
BarryG
Addict
Addict
Posts: 3293
Joined: Thu Apr 18, 2019 8:17 am

Re: Calculate the MB/s from know milliseconds and bytes

Post by BarryG »

STARGÅTE wrote: Tue Jan 25, 2022 8:36 am1 MB (mega byte) is a SI unit and exactly 1,000,000
What the hell? When did this change? 1 MB (megabyte) = 1,048,756 bytes since the dawn of computers. I'm not changing that view.
Simo_na
Enthusiast
Enthusiast
Posts: 177
Joined: Sun Mar 03, 2013 9:01 am

Re: Calculate the MB/s from know milliseconds and bytes

Post by Simo_na »

Thank You @ All

Ok, this is the right solution ? (i think) :)

Code: Select all

Global.q myms
Global.i mybytes
Global.d mymbs

mybytes = 2097152
myms = 653
mymbs = mybytes / myms * 1000 / 1024 / 1024

Debug StrD(mymbs,3) + " MB/s"
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Calculate the MB/s from know milliseconds and bytes

Post by NicTheQuick »

BarryG wrote: Tue Jan 25, 2022 9:18 am
STARGÅTE wrote: Tue Jan 25, 2022 8:36 am1 MB (mega byte) is a SI unit and exactly 1,000,000
What the hell? When did this change? 1 MB (megabyte) = 1,048,756 bytes since the dawn of computers. I'm not changing that view.
That was quite a while ago. :wink: Just read the Wiki article STARGÅTE has linked.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
BarryG
Addict
Addict
Posts: 3293
Joined: Thu Apr 18, 2019 8:17 am

Re: Calculate the MB/s from know milliseconds and bytes

Post by BarryG »

Yeah, I did read the article. It's all BS as far as I'm concerned, and only changed because regular non-computer people didn't understand why a MB wasn't 1,000,000 bytes; so the powers-that-be changed it to suit the noobs for marketing reasons. Sigh.
Simo_na
Enthusiast
Enthusiast
Posts: 177
Joined: Sun Mar 03, 2013 9:01 am

Re: Calculate the MB/s from know milliseconds and bytes

Post by Simo_na »

BarryG wrote: Tue Jan 25, 2022 10:52 am Yeah, I did read the article. It's all BS as far as I'm concerned, and only changed because regular non-computer people didn't understand why a MB wasn't 1,000,000 bytes; so the powers-that-be changed it to suit the noobs for marketing reasons. Sigh.
ok
I think the formula will still be the same, it changes the result a little, but the formula, that's it, right?
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Calculate the MB/s from know milliseconds and bytes

Post by NicTheQuick »

BarryG wrote: Tue Jan 25, 2022 10:52 am Yeah, I did read the article. It's all BS as far as I'm concerned, and only changed because regular non-computer people didn't understand why a MB wasn't 1,000,000 bytes; so the powers-that-be changed it to suit the noobs for marketing reasons. Sigh.
It changed because MB was not the same as MB and that's just confusing. Now it is MiB and that's all. It is now properly defined.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
BarryG
Addict
Addict
Posts: 3293
Joined: Thu Apr 18, 2019 8:17 am

Re: Calculate the MB/s from know milliseconds and bytes

Post by BarryG »

NicTheQuick wrote: Tue Jan 25, 2022 12:09 pmIt is now properly defined
Re-defined, just like so many other things these days.

Both MB and Megabyte always originally meant 1,048,576 bytes:

https://www.backblaze.com/blog/how-many ... te-really/

This is also evidenced in old computer magazine articles from the 60s, 70s and 80s.

From "History of the Computer" (https://studylib.net/doc/9055570/histor ... e-computer):

"MB stands for megabytes. 1048576 bytes"

From Microsoft's "Computer Basics: Student Edition" (https://www.uc.edu/webapps/af/hr/CUSTOM ... basics.pdf):

"After the kilobyte, the next largest unit is the megabyte. A megabyte (abbreviated M or MB) equals 1,048,576 bytes or characters".

Even Windows (the OS) shows a file of 1,048,576 bytes as being "1 MB" in size:

Image

Yes, I know I'm being pedantic about this, so I'll stop now.
Last edited by BarryG on Tue Jan 25, 2022 12:52 pm, edited 8 times in total.
User avatar
Caronte3D
Addict
Addict
Posts: 1027
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Calculate the MB/s from know milliseconds and bytes

Post by Caronte3D »

I always thought:
MB = MegaBytes
Mb = MegaBits
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Calculate the MB/s from know milliseconds and bytes

Post by STARGÅTE »

BarryG wrote: Tue Jan 25, 2022 10:52 am Yeah, I did read the article. It's all BS as far as I'm concerned, and only changed because regular non-computer people didn't understand why a MB wasn't 1,000,000 bytes; so the powers-that-be changed it to suit the noobs for marketing reasons. Sigh.
No. The "computer people" just defined MB (mega byte) as 1,048,576 byte even if the word mega is a SI prefix and is defined as 1,000,000 even before computer were present.
In terms of science, it was a necessary step to correct this (in my opinion).
BarryG wrote: Tue Jan 25, 2022 12:18 pm Even Windows (the OS) shows a file of 1,048,576 bytes as being "1 MB" in size:
Yes, but this doesn't mean that it is (still) correct. --> (in terms of a scientist)
As I said, when ever you bought a hard drive disk, the size is always in SI-units and then you wonder, why 10% size is missing in windows ^^
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Simo_na
Enthusiast
Enthusiast
Posts: 177
Joined: Sun Mar 03, 2013 9:01 am

Re: Calculate the MB/s from know milliseconds and bytes

Post by Simo_na »

and this ?

Image
User avatar
Michael Vogel
Addict
Addict
Posts: 2666
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Calculate the MB/s from know milliseconds and bytes

Post by Michael Vogel »

Cool - it's like talking about religion, politics or COVID :lol:

The personal perspective to this mega subject is not only a question of the geographical location but also of the personal age. When I started computing, technicans (they aren't scrientists, are they?) did say 'K' (=1024) not kilo ('k'=1000) and so a new 'M' (pronounced correctly as 'em') for 1<<20 was created additionally to the traditional 'M' (pronounced as mega) for 10^6. So all programs used 'M' (before 'Mi' has been invented) and a lot of them are still doing so.

Hard disks in the beginning of the computer era used the 'M' as well for 1024x1024, the simple reason why hard disk manufacturers understood to move (!) quickly using SI units is to maximize their profit.

@Simo_na - yes, your formula is perfect now :)
Simo_na
Enthusiast
Enthusiast
Posts: 177
Joined: Sun Mar 03, 2013 9:01 am

Re: Calculate the MB/s from know milliseconds and bytes

Post by Simo_na »

Michael Vogel wrote: Tue Jan 25, 2022 3:08 pm
Hard disks in the beginning of the computer era used the 'M' as well for 1024x1024, the simple reason why hard disk manufacturers understood to move (!) quickly using SI units is to maximize their profit.
not all, some have remained honest 8)
Post Reply