Open mhoward2718 opened 9 years ago
Cool!
From: mhoward2718 [mailto:notifications@github.com] Sent: Monday, March 23, 2015 4:48 PM To: p2t2/figaro Subject: [figaro] Debug as part of algorithm trait? Or in util? (#406)
Scala offers an annotation called @elidable, which tells the compiler to not to include calls to annotated methods in the resulting bytecode if a flag is set. We could unify our debugging statements by creating a function which accepts a string and just prints it to a log or stream, and use this annotation on it. We could add the function to the algorithm trait, or perhaps as globally accessible in util.
Could doing this this help our code coverage goal? I am not sure how scoverage deals with methods that have this annotation, or if adding the scoverage ignore annotation to the debug function would ignore calls throughout the code base. From a micro-optimization perspective, this would also remove all the branches which result from checking if (debug) before printing.
— Reply to this email directly or view it on GitHubhttps://github.com/p2t2/figaro/issues/406.
Coverage is measured by tests unit and otherwise, while your debug statements are in the main code, so the annotations won’t help with this. However, they would help to provide switchable debugging in the main code itself.
Can you also use it to switch off compiling? In C++ you can identify sections of code (through the header) and turn on/off compiling those sections depending on an external flag.
Glenn Takata Charles River Analytics Inc. 617.491.3474 x625 www.cra.comhttp://www.cra.com
From: apfeffer [mailto:notifications@github.com] Sent: Monday, March 23, 2015 4:49 PM To: p2t2/figaro Subject: Re: [figaro] Debug as part of algorithm trait? Or in util? (#406)
Cool!
From: mhoward2718 [mailto:notifications@github.com] Sent: Monday, March 23, 2015 4:48 PM To: p2t2/figaro Subject: [figaro] Debug as part of algorithm trait? Or in util? (#406)
Scala offers an annotation called @elidable, which tells the compiler to not to include calls to annotated methods in the resulting bytecode if a flag is set. We could unify our debugging statements by creating a function which accepts a string and just prints it to a log or stream, and use this annotation on it. We could add the function to the algorithm trait, or perhaps as globally accessible in util.
Could doing this this help our code coverage goal? I am not sure how scoverage deals with methods that have this annotation, or if adding the scoverage ignore annotation to the debug function would ignore calls throughout the code base. From a micro-optimization perspective, this would also remove all the branches which result from checking if (debug) before printing.
— Reply to this email directly or view it on GitHubhttps://github.com/p2t2/figaro/issues/406.
— Reply to this email directly or view it on GitHubhttps://github.com/p2t2/figaro/issues/406#issuecomment-85189036.
Yeah, this could potentially be useful, but I’d like more details on how it’s implemented. For example, is the switch at compile time or run time? Right now we can do runtime debugging switches, but if its compile time, then when we distribute the jar, people wouldn’t be able to run the debug code (unless we distributed the debug jars).
From: Glenn Takata [mailto:notifications@github.com] Sent: Tuesday, March 24, 2015 7:25 AM To: p2t2/figaro Subject: Re: [figaro] Debug as part of algorithm trait? Or in util? (#406)
Coverage is measured by tests unit and otherwise, while your debug statements are in the main code, so the annotations won’t help with this. However, they would help to provide switchable debugging in the main code itself.
Can you also use it to switch off compiling? In C++ you can identify sections of code (through the header) and turn on/off compiling those sections depending on an external flag.
Glenn Takata Charles River Analytics Inc. 617.491.3474 x625 www.cra.comhttp://www.cra.comhttp://www.cra.com%3chttp:/www.cra.com
From: apfeffer [mailto:notifications@github.com] Sent: Monday, March 23, 2015 4:49 PM To: p2t2/figaro Subject: Re: [figaro] Debug as part of algorithm trait? Or in util? (#406)
Cool!
From: mhoward2718 [mailto:notifications@github.com] Sent: Monday, March 23, 2015 4:48 PM To: p2t2/figaro Subject: [figaro] Debug as part of algorithm trait? Or in util? (#406)
Scala offers an annotation called @elidable, which tells the compiler to not to include calls to annotated methods in the resulting bytecode if a flag is set. We could unify our debugging statements by creating a function which accepts a string and just prints it to a log or stream, and use this annotation on it. We could add the function to the algorithm trait, or perhaps as globally accessible in util.
Could doing this this help our code coverage goal? I am not sure how scoverage deals with methods that have this annotation, or if adding the scoverage ignore annotation to the debug function would ignore calls throughout the code base. From a micro-optimization perspective, this would also remove all the branches which result from checking if (debug) before printing.
— Reply to this email directly or view it on GitHubhttps://github.com/p2t2/figaro/issues/406.
— Reply to this email directly or view it on GitHubhttps://github.com/p2t2/figaro/issues/406#issuecomment-85189036.
— Reply to this email directly or view it on GitHubhttps://github.com/p2t2/figaro/issues/406#issuecomment-85455515.
Scala offers an annotation called
@elidable
, which tells the compiler to not to include calls to annotated methods in the resulting bytecode if a flag is set. We could unify our debugging statements by creating a function which accepts a string and just prints it to a log or stream, and use this annotation on it. We could add the function to the algorithm trait, or perhaps as globally accessible in util.Could doing this this help our code coverage goal? I am not sure how scoverage deals with methods that have this annotation, or if adding the scoverage ignore annotation to the debug function would ignore calls throughout the code base. From a micro-optimization perspective, this would also remove all the branches which result from checking
if (debug)
before printing.