From b144e3a59142073e3323ad07f55ccb71cecabcf6 Mon Sep 17 00:00:00 2001 From: Dmitriy Kovalenko Date: Mon, 29 Apr 2024 15:54:30 +0200 Subject: [PATCH] Update readme --- README.md | 2 ++ bin/Main.ml | 4 ++-- bin/ODiffBin.ml | 4 ++-- bin/node-bindings/odiff.d.ts | 2 ++ bin/node-bindings/odiff.js | 4 ++++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ae48c616..5cbe090b 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,8 @@ export type ODiffOptions = Partial<{ antialiasing: boolean; /** If `true` reason: "pixel-diff" output will contain the set of line indexes containing different pixels */ captureDiffLines: boolean; + /** If `true` odiff will use less memory but will be slower with larger images */ + reduceRamUsage: boolean; /** An array of regions to ignore in the diff. */ ignoreRegions: Array<{ x1: number; diff --git a/bin/Main.ml b/bin/Main.ml index 9fc6b77c..dde201a2 100644 --- a/bin/Main.ml +++ b/bin/Main.ml @@ -14,7 +14,7 @@ type 'output diffResult = { exitCode : int; diff : 'output option } (* Arguments must remain positional for the cmd parser lib that we use *) let main img1Path img2Path diffPath threshold outputDiffMask failOnLayoutChange diffColorHex toEmitStdoutParsableString antialiasing ignoreRegions diffLines - disableMemoryOptimizations = + disableGcOptimizations = (* We do not need to actually maintain memory size of the allocated RAM by odiff, so we are increasing the minor memory size to avoid most of the possible deallocations. For sure it is @@ -22,7 +22,7 @@ let main img1Path img2Path diffPath threshold outputDiffMask failOnLayoutChange By default set the minor heap size to 256mb on 64bit machine *) - if not disableMemoryOptimizations then + if not disableGcOptimizations then Gc.set { (Gc.get ()) with diff --git a/bin/ODiffBin.ml b/bin/ODiffBin.ml index 14214045..200d160c 100644 --- a/bin/ODiffBin.ml +++ b/bin/ODiffBin.ml @@ -56,7 +56,7 @@ let diffLines = "With this flag enabled, output result in case of different images \ will output lines for all the different pixels" -let reduceMemory = +let disableGcOptimizations = value & flag & info [ "reduce-ram-usage" ] ~doc: @@ -83,7 +83,7 @@ let cmd = in ( const Main.main $ base $ comp $ diffPath $ threshold $ diffMask $ failOnLayout $ diffColor $ parsableOutput $ antialiasing $ ignoreRegions - $ diffLines $ reduceMemory, + $ diffLines $ disableGcOptimizations, Term.info "odiff" ~version:"3.0.0" ~doc:"Find difference between 2 images." ~exits: (Term.exit_info 0 ~doc:"on image match" diff --git a/bin/node-bindings/odiff.d.ts b/bin/node-bindings/odiff.d.ts index 886ba4b2..da12b132 100644 --- a/bin/node-bindings/odiff.d.ts +++ b/bin/node-bindings/odiff.d.ts @@ -13,6 +13,8 @@ export type ODiffOptions = Partial<{ antialiasing: boolean; /** If `true` reason: "pixel-diff" output will contain the set of line indexes containing different pixels */ captureDiffLines: boolean; + /** If `true` odiff will use less memory but will be slower with larger images */ + reduceRamUsage: boolean; /** An array of regions to ignore in the diff. */ ignoreRegions: Array<{ x1: number; diff --git a/bin/node-bindings/odiff.js b/bin/node-bindings/odiff.js index 20c4d311..b78815f7 100644 --- a/bin/node-bindings/odiff.js +++ b/bin/node-bindings/odiff.js @@ -50,6 +50,10 @@ function optionsToArgs(options) { setFlag("output-diff-lines", value); break; + case "reduceRamUsage": + setFlag("reduceRamUsage", value); + break; + case "ignoreRegions": { const regions = value .map(