Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Total number of lines in project

Credits go to Evert, Marcello, Matthew Leverton, and Onewing for helping out!
This thread is locked; no one can reply to it. rss feed Print
Total number of lines in project
Murat AYIK
Member #6,514
October 2005
avatar

I asked this in DevC++ mailing list(don't know why!) but can't get responses yet probably for that digest thing. Here it is:

> I like to see how many lines of code I wrote, but
> the project properties shows them per file. Is
> there a way to count the total number of lines in
> the whole project?

Currently I count them in "Project Properties" and write all numbers to windows calculator. With file numbers increasing that became harder.

_____________________________________________________
"The world doesn't care about what storms you sailed through, it is interested in whether you brought the ship to the dock or not!"

Onewing
Member #6,152
August 2005
avatar

You could write a little C/C++ program that simply reads the lines of every cpp file in the current directory and calculates the total for you.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Matthew Leverton
Supreme Loser
January 1999
avatar

  1. Download Unix tools for Windows:

  2. Or if you are too lazy to do that, then:

Marcello
Member #1,860
January 2002
avatar

Or use wc?

Evert
Member #794
November 2000
avatar

No need to use cat. wc * will print the total counts for all files at the bottom.

Murat AYIK
Member #6,514
October 2005
avatar

Quote:

You could write a little C/C++ program that simply reads the lines of every cpp file in the current directory and calculates the total for you.

This might be useful and easy. I need that info only for my main project, so a totally hardcoded prog can do what I want.

Quote:

Or if you are too lazy to do that, then:
type *.c > bigfile.c
Open up bigfile.c and count the lines.

Very nice! Combining this with the previous idea can decrease the coding time of that utility from 5 mins to 2 mins:)

EDIT:
I found the cat and wc tools but failed to use them. They start a console where I can write some commands apparently but I don't know what to write there.

EDIT2:
Nah, nevermind! I liked the "do-it-yourself" idea. It may turn into something better one day.

_____________________________________________________
"The world doesn't care about what storms you sailed through, it is interested in whether you brought the ship to the dock or not!"

Matthew Leverton
Supreme Loser
January 1999
avatar

Quote:

What is that?(I really don't know!)

It gives you the number of lines, words, and characters. Just read my post, point 1. Follow the link to download.

Quote:

I found the cat and wc tools but failed to use them. They start a console where I can write some commands apparently but I don't know what to write there.

Copy them to your Windows folder. Go to your programming folder (within a shell) and type:

wc *.c

Marcello
Member #1,860
January 2002
avatar

Or add the folder they're in to your system path (might be a better idea).

Marcello

ReyBrujo
Moderator
January 2001
avatar

Use grep to remove blank lines and comments, then wc to count. Maybe... cat *.c | grep -v "^\s*/*.*" | grep -v "^\s*//" | grep -v "^\s*$" | wc -l will work.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Marcello
Member #1,860
January 2002
avatar

That's cheating! You're supposed to include comments and blank lines. ;)

Marcello

Thomas Fjellstrom
Member #476
June 2000
avatar

Try sloccount.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Murat AYIK
Member #6,514
October 2005
avatar

Quote:

Use grep to remove blank lines and comments, then wc to count. Maybe... cat *.c | grep -v "^\s*/*.*" | grep -v "^\s*//" | grep -v "^\s*$" | wc -l will work.

What is that, ASCII art?:) I think it would be better to post a feature-request to the bloodshed guys.

Quote:

That's cheating! You're supposed to include comments and blank lines.

That's why I like DevCpp's built-in counter. It reports them seperately. I keep three numbers in my "comment.h" file; total lines, without empty lines and code lines only. The third doesn't really help your self-confidence;)

Quote:

Try sloccount

Seems like not so Windows-friendly!

I will try something tomorrow, it's 11PM. And sorry I'm out of cookies, Matthew gave me only one plate to serve:)(I know, wrong forum category!)

_____________________________________________________
"The world doesn't care about what storms you sailed through, it is interested in whether you brought the ship to the dock or not!"

HoHo
Member #4,534
April 2004
avatar

Some quite useless statistics about allegro. Statistics generated by sloccount.

Latest SVN version of 4.2:

Totals grouped by language (dominant language first):
ansic: 126573 (83.88%)
asm: 17018 (11.28%)
cpp: 3846 (2.55%)
sh: 2108 (1.40%)
objc: 925 (0.61%)
python: 216 (0.14%)
pascal: 179 (0.12%)
perl: 29 (0.02%)

Total Physical Source Lines of Code (SLOC) = 150,894
Development Effort Estimate, Person-Years (Person-Months) = 38.78 (465.39)
(Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
Schedule Estimate, Years (Months) = 2.15 (25.81)
(Basic COCOMO model, Months = 2.5 * (person-months**0.38))
Estimated Average Number of Developers (Effort/Schedule) = 18.03
Total Estimated Cost to Develop = $ 5,238,985
(average salary = $56,286/year, overhead = 2.40).

4.3:

Totals grouped by language (dominant language first):
ansic: 128564 (84.12%)
asm: 17011 (11.13%)
cpp: 3800 (2.49%)
sh: 2108 (1.38%)
objc: 925 (0.61%)
python: 216 (0.14%)
pascal: 179 (0.12%)
perl: 29 (0.02%)

Total Physical Source Lines of Code (SLOC) = 152,832
Development Effort Estimate, Person-Years (Person-Months) = 39.31 (471.67)
(Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
Schedule Estimate, Years (Months) = 2.16 (25.94)
(Basic COCOMO model, Months = 2.5 * (person-months**0.38))
Estimated Average Number of Developers (Effort/Schedule) = 18.19
Total Estimated Cost to Develop = $ 5,309,659
(average salary = $56,286/year, overhead = 2.40).

So, Allegro costs around $5,300,000. Not too bad for a ten year old thingie :)

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

GullRaDriel
Member #3,861
September 2003
avatar

Quote:

Total Estimated Cost to Develop = $ 5,309,659

See what you loose ! ;-X

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Murat AYIK
Member #6,514
October 2005
avatar

Quote:

Total Estimated Cost to Develop = $ 5,309,659
(average salary = $56,286/year, overhead = 2.40).

Well done, Hoho! Now noone will work on Allegro anymore without being paid:P

_____________________________________________________
"The world doesn't care about what storms you sailed through, it is interested in whether you brought the ship to the dock or not!"

HoHo
Member #4,534
April 2004
avatar

I think the effort estimate is a little off. I doubt combining all developers together would make four full-time developers over ten years.
of course there is always the chance that allegro developers are simply so good they can do the work of a ten devs in 1/10'th of the time ;D

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Evert
Member #794
November 2000
avatar

Quote:

pascal: 179 (0.12%)

Eh? ???

HoHo
Member #4,534
April 2004
avatar

hoho@box ~/katsepolygon/allegro-svn $  sloccount --details ./4.3/ | grep pascal
74      pascal  src_amd64       /home/hoho/katsepolygon/allegro-svn/4.3/src/amd64/asmdefs.inc
105     pascal  src_ppc /home/hoho/katsepolygon/allegro-svn/4.3/src/ppc/ppcdef.inc

I think it doesn't use anything else but file extensions to see what language is used.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Dustin Dettmer
Member #3,935
October 2003
avatar

Quote:

I think the effort estimate is a little off. I doubt combining all developers together would make four full-time developers over ten years.

It looks like it thinks it was made in 2.16 years, which makes sense since allegro is developed rather slowly compared to commercial products.

HoHo
Member #4,534
April 2004
avatar

Quote:

It looks like it thinks it was made in 2.16 years

... by 18.19 developers :)

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Tobias Dammers
Member #2,604
August 2002
avatar

1#include <allegro.h>
2 
3int main(int argc, char* argv[]) {
4 allegro_init();
5 int lines = 0;
6 
7 if (argc < 2)
8 return -1;
9 
10 PACKFILE* f = pack_fopen(argv[1], "rb");
11 
12 if (!f)
13 return -2;
14 
15 while (!pack_eof(f)) {
16 char c = pack_getc(f);
17 if (c == '\n')
18 ++lines;
19 }
20 printf("%s: %i lines.\n", argv[1], lines);
21 
22 return 0;
23}
24END_OF_MAIN()

:P

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Go to: