Skip to content

Commit

Permalink
Add option for global timeout to example.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hanno-becker committed Mar 15, 2024
1 parent 51f3fde commit ea6fd91
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, infile, name=None, funcname=None, suffix="opt",
def core(self, slothy):
slothy.optimize()

def run(self, debug=False, dry_run=False, silent=False):
def run(self, debug=False, dry_run=False, silent=False, timeout=0):

if dry_run is True:
annotation = " (dry run only)"
Expand Down Expand Up @@ -129,7 +129,9 @@ def run(self, debug=False, dry_run=False, silent=False):
slothy = Slothy(self.arch, self.target, logger=logger)
slothy.load_source_from_file(self.infile_full)

if self.timeout is not None:
if timeout != 0:
slothy.config.timeout = timeout
elif self.timeout is not None:
slothy.config.timeout = self.timeout

if dry_run is True:
Expand Down Expand Up @@ -1311,6 +1313,7 @@ def main():
parser.add_argument("--debug", default=False, action="store_true")
parser.add_argument("--silent", default=False, action="store_true")
parser.add_argument("--iterations", type=int, default=1)
parser.add_argument("--timeout", type=int, default=0)

args = parser.parse_args()
if args.examples != "all":
Expand All @@ -1332,7 +1335,7 @@ def run_example(name, **kwargs):
for e in todo:
for _ in range(iterations):
run_example(e, debug=args.debug, dry_run=args.dry_run,
silent=args.silent)
silent=args.silent, timeout=args.timeout)

if __name__ == "__main__":
main()

0 comments on commit ea6fd91

Please sign in to comment.