![]() |
Number of lines of code in user_routines.c
Hey guys!
My code is HUGE!! .. i mean huge.. well at least i think it is:D just an overall question for all u guys out there programming this year.. my code is nearly 800 lines of code... including comments.. My question to u guys is.. 'How many lines of code does ur program have just for user_routines.c (including side files)?' Just cuz im working on my camera code.. and went from 400 to 700...:eek:.... ima bad programmer... well not really... i just write long code! but then i end up breaking it down... if yu could let me noe:) that would be great! |
Re: Number of liines of code in user_routines.c
Quote:
|
Re: Number of liines of code in user_routines.c
Quote:
|
Re: Number of liines of code in user_routines.c
Yeah under a 1000 isnt bad. Also it has to do with how you code. Theres all sorts of ways to cut number of lines in half without changing anything.
Example PHP Code:
PHP Code:
|
Re: Number of liines of code in user_routines.c
Quote:
|
Re: Number of liines of code in user_routines.c
Yeah, depending on your style of coding and how many comments you actually add, the lines can vary tremendously. What's more important is the actual amount of data space you use. If you're using MPLAB (and I'm assuming you are), go to View->Memory Usage Gauge, and this will tell you both the amount of code and variable space you're using.
We overflowed the 2005 processor trying to get the camera and a driver perspective drive system with a gyro working. Last year we ended up using about 1/5 of the available space. |
Re: Number of liines of code in user_routines.c
So assuming some one uses a very inefficient coding style i.e something like this:
Code:
int values[3];Code:
for (int i =0; i<=2, i++) |
Re: Number of liines of code in user_routines.c
In an ideal world, yes, the compiler should do about the same thing. However, we're talking about MPLAB's compiler here, and it's far from "ideal". Something tells me even GCC would have difficulty optimizing it. My best bet goes to Intel's super-optimizing compiler. It's too bad we can't have something like that for our PICs.
As for code length in user_routines.c? It's only about 400-500. That's because I split my code up into multiple files. In all, I think I've written about 2000 in the pre-season this year. I've also taken the time to write my own camera code as opposed to Kevin's (it's good, just a little drawn out, IMHO). |
Re: Number of liines of code in user_routines.c
Quote:
The code from my team last year for FIRST is slightly over 900 lines, and that's before the precompiler includes all the files and stuff. Don't worry if your code's really large, maybe it's huge cuz it needs to be cuz it does a lot, who knows. |
Re: Number of liines of code in user_routines.c
The current code I have for user_routines.c is 111 lines long.
I gutted it (all those Limit_ functions are gone; I never used them) and I haven't put the drive code back in since the rewrite. That's why it's so short. Plus I have the code spread into other files I created, too. Don't worry about it being long. Worry about it being readable. Being up late in the shop night before ship date you may be tempted to just keep writing, but when you have to decipher it to figure out why autonomous mode did nothing, you will smack yourself if it isn't readable. JBot |
Re: Number of lines of code in user_routines.c
It's not code length... it's code functionality.
i believe ours was about 1,200 lines long... and i code in the most space saving style imaginable. |
Re: Number of lines of code in user_routines.c
Code length in C varies drastically based on style. If you use alot of functions your user_routine.c will be much shorter but you may have a huge header file some where.
|
Re: Number of lines of code in user_routines.c
Basically if your worried about space just remember to use the right data type. No reason to be keeping a counter that goes from 1 to 10 in an int.
|
| All times are GMT -5. The time now is 01:20. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi