We’ve all timed a clojure function using clojure’s `time` macro, and then wondered why we don’t get stable results. We’ve seen Rich show off order of magnitude speed differences in new versions of clojure using the time macro. But what happens when you want reliable benchmarks, that can track small changes in timings? `time` falls short.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ lein2 modules test | |
------------------------------------------------------------------------ | |
Module build order: | |
pallet-test-env-parent | |
lein-test-env | |
pallet-test-env | |
------------------------------------------------------------------------ | |
Building pallet-test-env-parent 0.1.2-SNAPSHOT (default) | |
------------------------------------------------------------------------ | |
Using JLine for console I/O; install rlwrap for optimum experience. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pallet.crate.maven.support-test | |
(:require | |
[clojure.test :refer :all] | |
[pallet.actions :refer [exec-checked-script exec-script* minimal-packages | |
package-manager]] | |
[pallet.api :refer [converge group-spec plan-fn]] | |
[pallet.build-actions :refer [build-actions build-session]] | |
[pallet.core.api :refer [phase-errors]] | |
[pallet.core.session :refer [with-session]] | |
[pallet.crate :refer [is-64bit?]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns lein-test-env.plugin) | |
(def profiles | |
{:aws {:pallet/test-env {} | |
:dependencies '[[com.palletops/pallet-aws "0.2.0"] | |
[ch.qos.logback/logback-classic "1.1.1"] | |
[org.slf4j/jcl-over-slf4j "1.7.6"]]}}) | |
(defn middleware | |
"Middleware to add test-env profiles" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pallet.api-examples.plan | |
"Examples of pallet's plan api" | |
(:refer-clojure :exclude [sync]) | |
(:require | |
[pallet.actions :refer [exec-script*]] | |
[pallet.core.executor.ssh :refer [ssh-executor]] | |
[pallet.plan :refer [execute-plan execute-plans plan-fn]] | |
[pallet.session :as session :refer [set-user]] | |
[pallet.user :refer [default-user]] | |
[pallet.utils.async :refer [sync]])) |
The choices of infrastructure is ever increasing - dedicated servers, VPS, cloud images, virtualisation and containers.
Each of these choices has advantages that suit a particular use case. A single application, when viewed from the development and operation perspective has many use cases however. Local virtualisation makes good sense for development. Ephemeral cloud nodes fit well for testing. Dedicated hardware is good choice for production in constant load environments. An image based solution is great
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ScopedTypeVariables #-} | |
module Test () where | |
-- a type class to specify parsing and encoding of a type | |
-- (in reality I'm using hedn, which is similar to aeson) | |
class T a where | |
f :: String -> a | |
g :: a -> String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns com.palletops.brick-server.fs-watch | |
"Watch a filesystem path" | |
(:require | |
[clojure.java.io :refer [file]] | |
[clojure.set :refer [map-invert]] | |
[clojure.tools.logging :refer [debugf]] | |
[clojure.string :refer [join]]) | |
(:import | |
[java.nio.file | |
ClosedWatchServiceException FileSystems Path StandardWatchEventKinds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar clojure-test-ediff-buffers nil) | |
(defun clojure-test-ediff-cleanup () | |
"A function for ediff-cleanup-hook, to cleanup the temporary ediff buffers" | |
(mapc #'kill-buffer clojure-test-ediff-buffers)) | |
(defconst re1 | |
"Expected \\(?:.\\|\n\\)*, got (not ([^ ]+ \\(\"\\(?:.\\|\n\\)+\"\\) \\(\"\\(?:.\\|\n\\)+\"\\)))" | |
"Match predicate on strings test") | |
(defconst re2 | |
"Expected \\(?:.\\|\n\\)*, got (not ([^ ]+ \\(\\(?:.\\|\n\\)+\\) \\(\\(?:.\\|\n\\)+\\)))" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro mfn* | |
[[argv] body & args] | |
(let [[argv] args] | |
body)) | |
(defmacro mfn | |
"An macro form which looks like an anonymous function, and can be used to | |
inline a function call " | |
[args body & arg-vals] | |
`(let [~args ~(vec arg-vals)] |