Instagram

Friday, March 28, 2008

geeky stuff

[migrated from livejournal]


and no, i am not a geek.

i have never been a fan of using linux. mostly because of how unfamiliar it is. you can't blame me though, it's, i think, part of human nature.
so...
recently, i had a turn about with regards to that certain opinion.

-----flashback
I have an addendum for our undergraduate research project...surprise surprise! I had to create an automated test  to stress test an MMC and the FAT16 file format. I consulted with Sir Atienza with regards to the parameter of the testing...and he told me that to at least project the stress test to about 2 years worth of use.

So, assuming continous usage, the firmware for the Axel Activity Monitor would write every (estimated) 9seconds. 8 seconds data gathering manipulation etc...1 sec (based on led blinking) to write and update and etc for the fat tables and data region.

So...if you have 512 bytes/9sec...translating that to 2 years worth of continous use...that's 3.6GB accumulated writings....hmmm well, with today's memory sizes, that may not be too large. but imagine having an excel file (2 columns of data) that's 3.6GB...you'll get the point.

at first i was pissed off again mostly because i didnt know anything with C that would be able to accomplish such automation. I have never really entertained the slightest possibility of using Linux. Well...not until this addendum...

oh yeah. instead of using 512 bytes...well, that's not really stress testing. so what i need to do is to write about 240MB (max size is 245MB) and project it to 2 years worth of read and write so that will be a total of 1,677,312,000,000,000 bytes by the end of two years... i will be simulating it to about 6,988,800 (times 240MB to get the amount mentioned)
-------------

So i learned that shell scripts would be best to accomplish that automation...
It started out a little tough considering that i didnt know the basic commands you can use
but...it pays to use Google (hahaha)

so now, ive managed to finish the program...
I should be running it soon enough...

and during the process of enjoying creating scripts on shell....i have actually been thinking of using ubuntu.

but....enough said. hahaha...i dont want to complicate my life yet.

here's how the code looks like (simple enough)
#!/bin/bash
counter=1
while [ $counter -le 6988800 ]
do
    echo "$counter"
    cp test.txt /media/sdc/move.txt
    diff -q test.txt /media/sdc/move.txt >> result.txt
    rm /media/sdc/move.txt
    counter=`expr $counter + 1`
done

the things i had trouble finding....
if you want to append to an already existing file...use
>>
the ones with expr are not ' ' but rather ` ` the one beside the key 1.

anyway. that's it for stress test.
i love doing shell scripts.
parang C programming only better.
simplified yung variable definitions...but siyempre it's not as easy as C.

PS:
i just left our desktop computer running...i programmed it to create the 240MB file necessary for the experiment. Haha! Im afraid it will finish by the time i wake up. I think my laptop is fragmented here and there. especially since i was creating a csv file that would have been continuous...hmm...nevermind thesis hang over. hahaha...the fat entries being updated every now and then when the file is manipulated. it sucks. i figured it would be better to leave it for the computer to accomplish. =)

thank you Lord for shell scripts...and Linux.

No comments:

Post a Comment