line-count

Can you get the number of lines of code from a GitHub repository?

旧巷老猫 提交于 2019-11-27 08:56:28
问题 In a GitHub repository you can see “language statistics”, which displays the percentage of the project that’s written in a language. It doesn’t, however, display how many lines of code the project consists of. Often, I want to quickly get an impression of the scale and complexity of a project, and the count of lines of code can give a good first impression. 500 lines of code implies a relatively simple project, 100,000 lines of code implies a very large/complicated project. So, is it possible

Fastest way to find the number of lines in a text (C++)

大兔子大兔子 提交于 2019-11-27 05:22:31
问题 I need to read the number of lines in a file before doing some operations on that file. When I try to read the file and increment the line_count variable at each iteration until i reach eof. It was not that fast in my case. I used both ifstream and fgets . They were both slow . Is there a hacky way to do this, which is also used by, for instance BSD, Linux kernel or berkeley db.(may be by using bitwise operations). As I told before there are millions of lines in that file and it keeps get

Count number of lines in a git repository

北战南征 提交于 2019-11-26 14:57:09
问题 How would I count the total number of lines present in all the files in a git repository? git ls-files gives me a list of files tracked by git. I'm looking for a command to cat all those files. Something like git ls-files | [cat all these files] | wc -l 回答1: xargs will do what you want: git ls-files | xargs cat | wc -l But with more information and probably better, you can do: git ls-files | xargs wc -l 回答2: git diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 This shows the differences

How to get line count of a large file cheaply in Python?

为君一笑 提交于 2019-11-25 22:20:02
问题 I need to get a line count of a large file (hundreds of thousands of lines) in python. What is the most efficient way both memory- and time-wise? At the moment I do: def file_len(fname): with open(fname) as f: for i, l in enumerate(f): pass return i + 1 is it possible to do any better? 回答1: You can't get any better than that. After all, any solution will have to read the entire file, figure out how many \n you have, and return that result. Do you have a better way of doing that without