• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #12818

pending completion
#12818

push

circleci

web-flow
Merge pull request #2911 from mozilla/MNTOR-1395

MNTOR-1395: Some benchmark tests for prod migration

282 of 1467 branches covered (19.22%)

Branch coverage included in aggregate %.

76 of 76 new or added lines in 3 files covered. (100.0%)

959 of 3992 relevant lines covered (24.02%)

2.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/scripts/prod-experiments/pullExperiment1000.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
/**
6
 * Executes once
7
 * The purpose of the script is to benchmark pure read with limit set as 1000
8
 */
9

10
import Knex from 'knex'
11
import knexConfig from '../../db/knexfile.js'
12
import { getAllBreachesFromDb } from '../../utils/hibp.js'
13
const knex = Knex(knexConfig)
×
14

15
const LIMIT = 1000 // with millions of records, we have to load a few at a time
×
16
let offset = 0 // looping through all records with offset
×
17
let subscribersArr = []
×
18

19
// load all breaches for ref
20
const allBreaches = await getAllBreachesFromDb()
×
21
if (allBreaches && allBreaches.length > 0) console.log('breaches loaded successfully! ', allBreaches.length)
×
22

23
const startTime = Date.now()
×
24
console.log(`Start time is: ${startTime}`)
×
25
do {
×
26
  console.log(`Converting breaches_resolved to breach_resolution - start: ${offset} limit: ${LIMIT}`)
×
27
  subscribersArr = await knex
×
28
    .select('id', 'primary_email', 'breaches_resolved', 'breach_resolution')
29
    .from('subscribers')
30
    .whereNotNull('breaches_resolved')
31
    .limit(LIMIT)
32
    .offset(offset)
33

34
  console.log(`Loaded # of subscribers: ${subscribersArr.length}`)
×
35

36
  offset += LIMIT
×
37
} while (subscribersArr.length === LIMIT)
38

39
// breaking out of do..while loop
40
console.log('Reaching the end of the table, offset ended at', offset)
×
41
const endTime = Date.now()
×
42
console.log(`End time is: ${endTime}`)
×
43
console.log('Diff is: ', endTime - startTime)
×
44
process.exit()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc