Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: implement filter query caching #456

Merged
merged 4 commits into from
Sep 9, 2023
Merged

perf: implement filter query caching #456

merged 4 commits into from
Sep 9, 2023

Conversation

KnorpelSenf
Copy link
Member

@KnorpelSenf KnorpelSenf commented Jun 29, 2023

// src/perf.ts
import { matchFilter } from "https://deno.land/x/[email protected]/mod.ts";
import { matchFilter as matchFilter2 } from "./mod.ts";

Deno.bench({
    name: "no-cache",
    baseline: true,
    fn: () => {
        matchFilter("::bold");
        matchFilter("message:dice");
        matchFilter("channel_post");
    },
});

Deno.bench({
    name: "cache",
    fn: () => {
        matchFilter2("::bold");
        matchFilter2("message:dice");
        matchFilter2("channel_post");
    },
});

gives

$ deno bench src/perf.ts 
cpu: Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
runtime: deno 1.34.3 (x86_64-unknown-linux-gnu)

file:https:///home/steffen/git/grammy/src/perf.ts
benchmark      time (avg)             (min … max)       p75       p99      p995
------------------------------------------------- -----------------------------
no-cache       15.11 µs/iter    (9.97 µs … 10.99 ms)  10.61 µs  39.51 µs  93.39 µs
cache         234.86 ns/iter (181.11 ns … 794.87 ns) 227.01 ns 490.52 ns 497.15 ns

summary
  no-cache
   64.33x slower than cache

Closes #447.

@codecov
Copy link

codecov bot commented Jun 29, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (08b0241) 46.39% compared to head (d6274af) 46.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #456      +/-   ##
==========================================
+ Coverage   46.39%   46.41%   +0.01%     
==========================================
  Files          19       19              
  Lines        5610     5617       +7     
  Branches      222      224       +2     
==========================================
+ Hits         2603     2607       +4     
- Misses       3004     3007       +3     
  Partials        3        3              
Files Changed Coverage Δ
src/filter.ts 90.25% <100.00%> (-0.78%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@rojvv rojvv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfy!

@KnorpelSenf KnorpelSenf merged commit 1a6fe9f into main Sep 9, 2023
8 checks passed
@KnorpelSenf KnorpelSenf deleted the query-caching branch September 9, 2023 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

perf: filter query caching
2 participants