Home > Back-end >  Mechanical drive 4 k is not random, speaking, reading and writing very slow? Why do I have more than
Mechanical drive 4 k is not random, speaking, reading and writing very slow? Why do I have more than

Time:04-30

My code has a problem?
Long blockSize=(long) 2 & lt; <10;
Long totalSize=4 l & lt; <30;
Long totalCount=totalSize/blockSize;
SeekableByteChannel outputStream=Files. NewByteChannel (Paths. The get (" D: \ \ test "), StandardOpenOption. WRITE, StandardOpenOption. CREATE, StandardOpenOption. DELETE_ON_CLOSE);
ByteBuffer data=https://bbs.csdn.net/topics/ByteBuffer.allocate ((int) blockSize);
The Random Random=new Random (System. CurrentTimeMillis ());
Long startTime=System. CurrentTimeMillis ();
For (long I=0; I & lt; TotalCount; I++) {
OutputStream. Position (Math. Abs (random nextInt ()));
OutputStream. Write (data);
}
outputStream.close();
Long stopTime=System. CurrentTimeMillis ();
System. Out.println (totalSize * 1000.0/(stopTime - startTime)/(1 & lt; <20));

CodePudding user response:

More than 100 M/s normal ah, if can not reach this speed, or some other place to have a bottleneck that code, I've tested,

CodePudding user response:

The cache is used up you will find more slowly

CodePudding user response:

The original poster is to compare? Even the mechanical drive, the read and write speed of 100 m/S is normal, the original poster should run a on SSD, to see the effect, but there is no point in having a mechanical drive slow, no comparison, no damage,

CodePudding user response:

https://www.baidu.com/s? Wd=9 BA c % % % % E6 E6 A1 A2 E7 B0 % % % % % % AC E7 9 b % % % % % 984 k % E8 AF BB E5 E9 86% % 99% % 80% BA E5 9 f % % % A6 & amp; RSF=64050023 & amp; RSP=0 & amp; F=1 & amp; Oq=9 BA c % % % % E6 E6 A1 A2 E7 B0 % % % % % % AC E7 E9%9 b % 984 k % % % a % 8 of 9 f % E6 9 BB AF E8 BA c % % % % % E5 E9 86% % 99% % 80% BA E5 9 f % % % A6 & amp; Tn=58025142 _5_oem_dg & amp; Ie=utf-8 & amp; Rsv_pq=87 edea5200045a89 & amp; Rsv_t=76 b9qylkptjcxs4qjuti1df3tivyk2bgoyh8ct2l3ut1qbewcv4e7zdgevdfxi1oyjso8dsieky & amp; Rqlang=cn& rs_src=https://bbs.csdn.net/topics/0

http://tieba.baidu.com/p/4869119339

http://tieba.baidu.com/p/2883354675

The somebody else SSD 4 k is random, speaking, reading and writing to more than 20 M/s

CodePudding user response:

Now ordinary SATA serial hard drives are at least 150 m/s speed, SATA 3.0 peak can reach 600 m/s, but because the other hardware or PC status limit cannot be achieved, if your SSD is SATA interface, 3.0 in theory can reach 6 g/s but is actually up to 700 m/s, with m. 2 interface will be a lot faster,

CodePudding user response:

reference 5 floor qq_39936465 reply:
ordinary SATA serial hard disk at least are now at a speed of 150 m/s, SATA 3.0 peak can reach 600 m/s, but because the other hardware or PC status limit cannot be achieved, if your SSD is SATA interface, 3.0 in theory can reach 6 g/s but is actually up to 700 m/s, with m. 2 interface will be a lot faster,

Why their evaluation inside solid 4 k random reading and writing is more than 20 M/s, my program of mechanical drive can reach more than 100 M/s, is not my code 4 k random write? Or are they to evaluate different definition of random, speaking, reading and writing?

CodePudding user response:

reference 1/f, madness walker response:
100 M/s normal ah, if can not reach this speed, or else where bottlenecks that code, I've tested,

Why online measurement of the SSD 4 k random reading and writing to more than 20 M/s, is slower than mechanical hard disk? Those random testing software code is random, speaking, reading and writing, speaking, reading and writing and the above two definitions?

CodePudding user response:

refer to the second floor yalishandazhu response:
cache is used up you will find more slowly

Wrote a total of 4 g, the content of the cache is useless over? There are so big?

CodePudding user response:

Code has a problem, I run on my computer and found that no disk file !

CodePudding user response:

references 9 f zhangpeterx response:
code has a problem, I run on my computer and found that file no disk !


"The findings on!" ?????

CodePudding user response:

references to the tenth floor ended half Angle response:
Quote: references 9 f zhangpeterx response:

Code has a problem, I run on my computer and found that no disk file !


"The findings on!" ?????

You put the StandardOpenOption DELETE_ON_CLOSE commented out, the file is written to disk, as you can see the file size is not 4 g

CodePudding user response:

Zhangpeterx
reference 11 floor response:
Quote: reference to the tenth floor half Angle end response:

Quote: references 9 floor zhangpeterx response:

Code has a problem, I run on my computer and found that no disk file !


"The findings on!" ?????

You put the StandardOpenOption DELETE_ON_CLOSE commented out, the file is written to disk, you can see the file size is not 4 g


Write position are random, will cover the content of the written before, so the file size can't be a 4 g, to test the order not to write, write is random,

CodePudding user response:

half Angle refer to 12 floor full stop response:
Quote: reference 11 floor zhangpeterx response:

Quote: reference to the tenth floor ended half Angle response:

Quote: references 9 floor zhangpeterx response:

Code has a problem, I run on my computer and found that no disk file !


"The findings on!" ?????

You put the StandardOpenOption DELETE_ON_CLOSE commented out, the file is written to disk, you can see the file size is not 4 g


Write position are random, will cover the content of the written before, so the file size can't be a 4 g, to test the order not to write, write is random,



Somebody else 4 k is random, speaking, reading and writing to the hard disk, the random read and write is a file, you difference is big, measured data is higher than hard drive speed measuring software is normal, unless you write the file with the hard disk,

CodePudding user response:

More than 100 m and can't work, now high can also download speed to 100 m

CodePudding user response:


You write this is not random, it is order to write, write a 4 k, continuous wrote 4 G,
nullnullnullnullnullnullnullnull