Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@monkcs Thanks for the tip! I'll make sure I use that technique in every program I write from now on
-
Maybe He wanted to calculate PI for 10000000 decimal places and now found out he could just copy already know decimals and paste them into His codeπ€
-
eis6aer3738yI feel dumb since i was excited from turning a 10 million insterts from a query, from 1.5 minutes to 1.1 minutes :(
-
I am using something like a linked list + struct pointer, which is filled by a push function. This function loops over the entire list and appends to the last node. I removed the function and merged it with the filler loop (which is linux' nftw() btw) and made one string array in the struct to a string pointer, because otherwise the program allocates 4kb ram per node. Now the program only needs 0.005 seconds and ram usage went from 2.5 GB to 180 MB.
-
@monkcs I collected all data about every file in a soecific directory. In this case, my main NAS, which has about 6 TB files.
-
@monkcs Well, i honestly thought that. I checked everything, including printing out and core dumps. It worked.
-
@PenguinRage @wolt Well, when using liked lists the push function costs rises lineary, because it has to loop over everything. The nftw function has a callback function, which previously just called push(). Now i stored the current node in a global variable, which allows the callback to remember the position of its last append. So, performance never decreases. If you want i can give you the repo link :)
-
DRHAX3414498ySo before it lasted 74 mins before it would crash, now it takes 0.005 seconds to crash? π
-
Root824848yFacepalm. Your original approach was very flawed.
Saving a pointer to the last node is a solution, as is passing the pointer to your push function. You should avoid using global vars, though -
@Ashkin Yes, it was. But it is my first use of datastructures other than arrays.
-
m93mark2758yTo quote my old computer architecture professor: when you write a software add useless loops around to have bad performances and release /sell as version 1.0, then remove some of them and release version 2.0 with "hey buy version 2.0, it is n times faster than 1.0"
-
Nice job. But I wonder how the 74min thing was accepted at the first place
It seems it's obvious something wrong. -
tmux20198yOn the other hand, you had created a program that actually needed 0.005 seconds and took 74 minutes. That's a really bad day!
-
tmux20198y@vortexman100 you should feel good. You came back to refactor. You are better than 99% of us from this alone.
-
@tmux "You came back to refactor" sounds a bit like "You came back to take revenge and your rightful place as the king" or something...
-
kraator4137yint main() {
return 42; // fixes performance issue
// return computeAnswerToLifeTheUniverseAndEverything();
}
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
elgringo41Student - Teacher renaming .c to .exe make the program executable ? Teacher - Yes A group of people stand up...
-
adracea18So...Today I found an SQLI (sql injection , google if you're not aware) in one of our products , I start explo...
Optimized my program fron running 74 minutes to running 0.005 seconds. I call that a successful day.
undefined
c
success
optimization