MCPcopy Index your code
hub / github.com/nodejs/node / count_lines_of_unit

Function count_lines_of_unit

deps/v8/tools/locs.py:394–419  ·  view source on GitHub ↗
(ikey)

Source from the content-addressed store, hash-verified

392 cmd_splitter = CommandSplitter()
393
394 def count_lines_of_unit(ikey):
395 i, key = ikey
396 if not result.track(key['file']):
397 return
398 message = "[{}/{}] Counting LoCs of {}".format(
399 i, len(compile_commands), key['file'])
400 status.print(message, file=out)
401 clangcmd, infilename, infile, outfilename = cmd_splitter.process(key)
402 if not infile.is_file():
403 return
404
405 clangcmd = clangcmd + " -E -P " + \
406 str(infile) + " -o /dev/stdout | sed '/^\\s*$/d' | wc -lc"
407 loccmd = ("cat {} | sed '\\;^\\s*//;d' | sed '\\;^/\\*;d'"
408 " | sed '/^\\*/d' | sed '/^\\s*$/d' | wc -lc")
409 loccmd = loccmd.format(infile)
410 runcmd = " {} ; {}".format(clangcmd, loccmd)
411 if ARGS['echocmd']:
412 print(runcmd)
413 process = subprocess.Popen(
414 runcmd, shell=True, cwd=key['directory'], stdout=subprocess.PIPE)
415 p = {'process': process, 'infile': infilename, 'outfile': outfilename}
416 output, _ = p['process'].communicate()
417 expanded, expanded_bytes, loc, in_bytes = list(map(int, output.split()))
418 result.recordFile(p['infile'], p['outfile'], loc,
419 in_bytes, expanded, expanded_bytes)
420
421 with tempfile.TemporaryDirectory(dir='/tmp/', prefix="locs.") as temp:
422 start = time.time()

Callers

nothing calls this directly

Calls 10

strFunction · 0.85
trackMethod · 0.80
recordFileMethod · 0.80
printFunction · 0.70
formatMethod · 0.65
listFunction · 0.50
mapFunction · 0.50
printMethod · 0.45
processMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…