def _setup(contents): class FakeConfig(object): filename = os.path.join(TEST_DIR, "manifest_tests.krun") config = FakeConfig() with open(ManifestManager.get_filename(config), "w") as fh: fh.write(contents) return ManifestManager(config, MockPlatform(None, config))
def test_get_session_info0002(): path = os.path.join(TEST_DIR, "more_complicated.krun") config = Config(path) info = get_session_info(config) # 6 benchmarks, 9 VMs, skipped 3 exact keys, and all 6 CPython keys # Then two repetitions (process executions) of all of the above. expect_proc_execs = (6 * 9 - 3 - 6) * 2 assert info["n_proc_execs"] == expect_proc_execs # 2000 in-process iterations assert info["n_in_proc_iters"] == expect_proc_execs * 2000 expect_skip_keys = [ "fasta:TruffleRuby:default-ruby", "richards:HHVM:default-php", "spectralnorm:TruffleRuby:default-ruby", "binarytrees:CPython:default-python", "richards:CPython:default-python", "spectralnorm:CPython:default-python", "nbody:CPython:default-python", "fasta:CPython:default-python", "fannkuch_redux:CPython:default-python", ] assert info["skipped_keys"] == set(expect_skip_keys) expect_non_skipped_keys = [ 'richards:C:default-c', 'nbody:HHVM:default-php', 'binarytrees:C:default-c', 'binarytrees:PyPy:default-python', 'spectralnorm:Hotspot:default-java', 'fannkuch_redux:Graal:default-java', 'nbody:TruffleRuby:default-ruby', 'fasta:Graal:default-java', 'binarytrees:Graal:default-java', 'fasta:C:default-c', 'binarytrees:TruffleRuby:default-ruby', 'spectralnorm:HHVM:default-php', 'nbody:PyPy:default-python', 'fannkuch_redux:C:default-c', 'fannkuch_redux:TruffleRuby:default-ruby', 'fannkuch_redux:Hotspot:default-java', 'spectralnorm:PyPy:default-python', 'fasta:PyPy:default-python', 'binarytrees:Hotspot:default-java', 'nbody:C:default-c', 'richards:TruffleRuby:default-ruby', 'fasta:V8:default-javascript', 'nbody:V8:default-javascript', 'richards:V8:default-javascript', 'nbody:LuaJIT:default-lua', 'richards:Hotspot:default-java', 'fasta:LuaJIT:default-lua', 'binarytrees:LuaJIT:default-lua', 'fannkuch_redux:V8:default-javascript', 'fannkuch_redux:LuaJIT:default-lua', 'richards:Graal:default-java', 'binarytrees:V8:default-javascript', 'spectralnorm:LuaJIT:default-lua', 'spectralnorm:C:default-c', 'fannkuch_redux:HHVM:default-php', 'fannkuch_redux:PyPy:default-python', 'binarytrees:HHVM:default-php', 'fasta:HHVM:default-php', 'spectralnorm:V8:default-javascript', 'spectralnorm:Graal:default-java', 'nbody:Graal:default-java', 'richards:LuaJIT:default-lua', 'nbody:Hotspot:default-java', 'richards:PyPy:default-python', 'fasta:Hotspot:default-java' ] assert info["non_skipped_keys"] == set(expect_non_skipped_keys) # There should be no overlap in the used and skipped keys assert info["skipped_keys"].intersection(info["non_skipped_keys"]) == set() os.unlink(ManifestManager.get_filename(config))
def _setup(contents): class FakeConfig(object): filename = os.path.join(TEST_DIR, "manifest_tests.krun") config = FakeConfig() with open(ManifestManager.get_filename(config), "w") as fh: fh.write(contents) return ManifestManager(config, MockPlatform(None, config))
def test_get_session_info0001(): path = os.path.join(TEST_DIR, "example.krun") config = Config(path) info = get_session_info(config) assert info["n_proc_execs"] == 8 assert info["n_in_proc_iters"] == 40 assert info["skipped_keys"] == set() expect_non_skipped_keys = set([ "dummy:Java:default-java", "nbody:Java:default-java", "dummy:CPython:default-python", "nbody:CPython:default-python", ]) assert info["non_skipped_keys"] == expect_non_skipped_keys os.unlink(ManifestManager.get_filename(config))
def test_get_session_info0001(): path = os.path.join(TEST_DIR, "example.krun") config = Config(path) info = get_session_info(config) assert info["n_proc_execs"] == 8 assert info["n_in_proc_iters"] == 40 assert info["skipped_keys"] == set() expect_non_skipped_keys = set([ "dummy:Java:default-java", "nbody:Java:default-java", "dummy:CPython:default-python", "nbody:CPython:default-python", ]) assert info["non_skipped_keys"] == expect_non_skipped_keys os.unlink(ManifestManager.get_filename(config))
def test_get_session_info0002(): path = os.path.join(TEST_DIR, "more_complicated.krun") config = Config(path) info = get_session_info(config) # 6 benchmarks, 9 VMs, skipped 3 exact keys, and all 6 CPython keys # Then two repetitions (process executions) of all of the above. expect_proc_execs = (6 * 9 - 3 - 6) * 2 assert info["n_proc_execs"] == expect_proc_execs # 2000 in-process iterations assert info["n_in_proc_iters"] == expect_proc_execs * 2000 expect_skip_keys = [ "fasta:TruffleRuby:default-ruby", "richards:HHVM:default-php", "spectralnorm:TruffleRuby:default-ruby", "binarytrees:CPython:default-python", "richards:CPython:default-python", "spectralnorm:CPython:default-python", "nbody:CPython:default-python", "fasta:CPython:default-python", "fannkuch_redux:CPython:default-python", ] assert info["skipped_keys"] == set(expect_skip_keys) expect_non_skipped_keys = [ 'richards:C:default-c', 'nbody:HHVM:default-php', 'binarytrees:C:default-c', 'binarytrees:PyPy:default-python', 'spectralnorm:Hotspot:default-java', 'fannkuch_redux:Graal:default-java', 'nbody:TruffleRuby:default-ruby', 'fasta:Graal:default-java', 'binarytrees:Graal:default-java', 'fasta:C:default-c', 'binarytrees:TruffleRuby:default-ruby', 'spectralnorm:HHVM:default-php', 'nbody:PyPy:default-python', 'fannkuch_redux:C:default-c', 'fannkuch_redux:TruffleRuby:default-ruby', 'fannkuch_redux:Hotspot:default-java', 'spectralnorm:PyPy:default-python', 'fasta:PyPy:default-python', 'binarytrees:Hotspot:default-java', 'nbody:C:default-c', 'richards:TruffleRuby:default-ruby', 'fasta:V8:default-javascript', 'nbody:V8:default-javascript', 'richards:V8:default-javascript', 'nbody:LuaJIT:default-lua', 'richards:Hotspot:default-java', 'fasta:LuaJIT:default-lua', 'binarytrees:LuaJIT:default-lua', 'fannkuch_redux:V8:default-javascript', 'fannkuch_redux:LuaJIT:default-lua', 'richards:Graal:default-java', 'binarytrees:V8:default-javascript', 'spectralnorm:LuaJIT:default-lua', 'spectralnorm:C:default-c', 'fannkuch_redux:HHVM:default-php', 'fannkuch_redux:PyPy:default-python', 'binarytrees:HHVM:default-php', 'fasta:HHVM:default-php', 'spectralnorm:V8:default-javascript', 'spectralnorm:Graal:default-java', 'nbody:Graal:default-java', 'richards:LuaJIT:default-lua', 'nbody:Hotspot:default-java', 'richards:PyPy:default-python', 'fasta:Hotspot:default-java' ] assert info["non_skipped_keys"] == set(expect_non_skipped_keys) # There should be no overlap in the used and skipped keys assert info["skipped_keys"].intersection(info["non_skipped_keys"]) == set() os.unlink(ManifestManager.get_filename(config))
def main(parser): args = parser.parse_args() if args.dump is not None: if not args.filename.endswith(".json.bz2"): usage(parser) else: Results.ok_to_instantiate = True results = Results(None, None, results_file=args.filename) text = results.dump(args.dump) # String data read in from JSON are unicode objects. This matters # for us as some data in the audit includes unicode characters. # If it does, a simple print no longer suffices if the system # locale is (e.g.) ASCII. In this case print will raise an # exception. The correct thing to do is to encode() the unicode to # the system locale. print(text.encode(locale.getpreferredencoding())) sys.exit(0) if not args.filename.endswith(".krun"): usage(parser) try: if os.stat(args.filename).st_size <= 0: util.fatal('Krun configuration file %s is empty.' % args.filename) except OSError: util.fatal('Krun configuration file %s does not exist.' % args.filename) config = Config(args.filename) if args.info: # Info mode doesn't run the experiment. # Just prints some metrics and exits. util.print_session_info(config) return manifest_filename = ManifestManager.get_filename(config) on_first_invocation = not (os.path.isfile(manifest_filename) and os.stat(manifest_filename).st_size > 0) log_file = config.log_filename() if on_first_invocation and os.path.exists(log_file): util.fatal("Log file '%s' already exists. " "Move the file away before running Krun." % log_file) attach_log_file(config, not on_first_invocation) debug("Krun invoked with arguments: %s" % sys.argv) mail_recipients = config.MAIL_TO if type(mail_recipients) is not list: util.fatal("MAIL_TO config should be a list") mailer = Mailer(mail_recipients, max_mails=config.MAX_MAILS) try: inner_main(mailer, on_first_invocation, config, args) except Exception as exn: error_info = sys.exc_info() subject = "Fatal Krun Exception" lines = ["Fatal Krun error: %s\n" % str(error_info[1])] for frame in traceback.format_tb(error_info[2]): lines.append(frame) msg = "".join(lines) util.log_and_mail(mailer, debug, subject, msg, bypass_limiter=True) raise exn
def main(parser): args = parser.parse_args() if args.dump is not None: if not args.filename.endswith(".json.bz2"): usage(parser) else: Results.ok_to_instantiate = True results = Results(None, None, results_file=args.filename) text = results.dump(args.dump) # String data read in from JSON are unicode objects. This matters # for us as some data in the audit includes unicode characters. # If it does, a simple print no longer suffices if the system # locale is (e.g.) ASCII. In this case print will raise an # exception. The correct thing to do is to encode() the unicode to # the system locale. print(text.encode(locale.getpreferredencoding())) sys.exit(0) if not args.filename.endswith(".krun"): usage(parser) try: if os.stat(args.filename).st_size <= 0: util.fatal('Krun configuration file %s is empty.' % args.filename) except OSError: util.fatal('Krun configuration file %s does not exist.' % args.filename) config = Config(args.filename) if args.info: # Info mode doesn't run the experiment. # Just prints some metrics and exits. util.print_session_info(config) return manifest_filename = ManifestManager.get_filename(config) on_first_invocation = not (os.path.isfile(manifest_filename) and os.stat(manifest_filename).st_size > 0) log_file = config.log_filename() if on_first_invocation and os.path.exists(log_file): util.fatal("Log file '%s' already exists. " "Move the file away before running Krun." % log_file) attach_log_file(config, not on_first_invocation) debug("Krun invoked with arguments: %s" % sys.argv) mail_recipients = config.MAIL_TO if type(mail_recipients) is not list: util.fatal("MAIL_TO config should be a list") mailer = Mailer(mail_recipients, max_mails=config.MAX_MAILS) try: inner_main(mailer, on_first_invocation, config, args) except Exception as exn: error_info = sys.exc_info() subject = "Fatal Krun Exception" lines = ["Fatal Krun error: %s\n" % str(error_info[1])] for frame in traceback.format_tb(error_info[2]): lines.append(frame) msg = "".join(lines) util.log_and_mail(mailer, debug, subject, msg, bypass_limiter=True) raise exn