priv-kweihmann / multimetric

Calculate code metrics in various languages
zlib License
36 stars 13 forks source link

import multimetric and use it #25

Closed lStiven closed 2 years ago

lStiven commented 2 years ago

Hi, I have a question, could I import multimetric in a python class? and use it programmatically? Right now, I'm using it with subprocess import

import subprocess
import json

info = subprocess.run(["multimetric", "example.py"], capture_output=True)
info_to_json = json.loads(info.stdout.decode("utf-8"))
priv-kweihmann commented 2 years ago

Hi, currently that not supported, but I think I could implement that easily if that is needed

lStiven commented 2 years ago

I'm going to talk to you in Spanish, because I don't know how to express the words in English. La pregunta anterior surge porque me genera curiosidad de que manera el tiempo de ejecución de tu herramienta es más rápido, ya sea apoyandome del módulo -subprocess- o usándolo programáticamente.

google-translate

"The previous question arises because it makes me curious in which way the execution time of your tool is faster, either by relying on the -subprocess- module or using it programmatically"

priv-kweihmann commented 2 years ago

I think there isn't that much of a difference. What's slow about setting up a new python process this the python import system (the more import you have the slower it gets). I think with this tool there aren't that many imports. Most of the time in this tool is spend parser the provided sources with pygments and doing the calculations... and that won't go away if you just import it into a different process.

Also I'd like to highlight the positive side of using processes... you never accidentally reuse calculations from previous files, as all memory (used for storing) is "fresh" in a new process.

In total I think it's fine to use your way of invoking the tool with the help of subprocess

priv-kweihmann commented 2 years ago

I close this one for now - fell free to open an enhancement for importing the tool, if you still think that is needed

priv-kweihmann commented 1 year ago

FYI: Part of release 2.0.0