Is there any way of detecting if a drive is a SSD?

前端 未结 9 2049
面向向阳花
面向向阳花 2020-11-30 03:02

I\'m getting ready to release a tool that is only effective with regular hard drives, not SSD (solid state drive). In fact, it shouldn\'t be used with SSD\'s because it will

9条回答
  •  萌比男神i
    2020-11-30 03:56

    write text file
    read text file

    repeat 10000 times...

    10000/elapsed

    for an ssd will be much higher, python3:

    def ssd_test():
    
        doc = 'ssd_test.txt'
        start = time.time()
        for i in range(10000):
            with open(doc, 'w+') as f:
                f.write('ssd test')
                f.close()
            with open(doc, 'r') as f:
                ret = f.read()
                f.close()
        stop = time.time()
        elapsed = stop - start
        ios = int(10000/elapsed)
        hd = 'HDD'
        if ios > 6000: # ssd>8000; hdd <4000
            hd = 'SSD'
        print('detecting hard drive type by read/write speed')
        print('ios', ios, 'hard drive type', hd)
        return hd
    

提交回复
热议问题