diff --git a/third_party/lisp/mime4cl/.skip-subtree b/third_party/lisp/mime4cl/.skip-subtree deleted file mode 100644 index 5051f60d6..000000000 --- a/third_party/lisp/mime4cl/.skip-subtree +++ /dev/null @@ -1 +0,0 @@ -prevent readTree from creating entries for subdirs that don't contain an .nix files diff --git a/third_party/lisp/mime4cl/benchmark/bench.lisp b/third_party/lisp/mime4cl/benchmark/bench.lisp new file mode 100644 index 000000000..1a25f2010 --- /dev/null +++ b/third_party/lisp/mime4cl/benchmark/bench.lisp @@ -0,0 +1,30 @@ +(defpackage :mime4cl-bench + (:use :common-lisp :mime4cl) + (:export :main)) + +(in-package :mime4cl-bench) + +;; Write to /dev/null so that I/O is less (?) of a factor +(defparameter *output-path* (pathname "/dev/null")) + +(defun parse-message (path) + (let ((msg (mime-message path))) + ;; to prove we are doing something, print the subject + (format t "Subject: ~A~%" (car (mime-message-header-values "Subject" msg :decode t))) + msg)) + +(defun main () + (destructuring-bind (bench-name message-path) (uiop:command-line-arguments) + (let ((action (intern (string-upcase bench-name) :mime4cl-bench)) + (message-path (pathname message-path))) + (ccase action + ((parse) (parse-message message-path)) + ((extract) (do-parts (part (parse-message message-path)) + (format t "Content-Type: ~A~%" (mime-type-string part)) + (let ((in (mime-body-stream part))) + (with-open-file (output-stream (pathname *output-path*) + :direction :output + :if-does-not-exist :create + :element-type (stream-element-type in) + :if-exists :overwrite) + (redirect-stream in output-stream))))))))) diff --git a/third_party/lisp/mime4cl/benchmark/default.nix b/third_party/lisp/mime4cl/benchmark/default.nix new file mode 100644 index 000000000..b201ede74 --- /dev/null +++ b/third_party/lisp/mime4cl/benchmark/default.nix @@ -0,0 +1,69 @@ +{ depot, pkgs, lib, ... }: + +let + # Example email that's going to push the parser due to its big attachment + # of almost 200MB. We are using a GHC bindist since it's quite big and a + # fixed output derivation that's already part of nixpkgs, so whitby only + # needs to download it once (and it won't change). + message = pkgs.runCommand "huge.mime" + { + nativeBuildInputs = [ pkgs.buildPackages.mblaze ]; + } + '' + mmime > $out <