ajv-validator / ajv-validator/ajv

v7: schema compilation is safer but significantly slower than v6 - using standalone validation code

Aperta
#1,386 6 commenti 2 reazioni 0 assegnatari Vedi su GitHub
docs
Lingua principale
TypeScript
Stelle
14.8k
Fork
1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

In Serverless Framework we've just upgrade AJV from v6 to v7, and observed that `ajv.compile(schema)` execution time for very same schema jumped from ca `0.15s` to `0.8s`.

Is this a known issue?

It can be observed by running any Serverless Framework command, and measuring execution time at this line:

https://github.com/serverless/serverless/blob/bcbbd47fa09b7d99d7f8da3f11150215d1203bba/lib/classes/ConfigSchemaHandler/index.js#L106

**What version of Ajv are you using? Does the issue happen if you use the latest version?**

v7.0.3

**Ajv options object**

```javascript
{ allErrors: true, coerceTypes: 'array', verbose: true, strict: false }
```

**JSON Schema**

It's a large dynamically generated schema, if needed I can export it to JSON and provide a link

**Your code**

```javascript
const Ajv = require('ajv').default;
const ajv = new Ajv({ allErrors: true, coerceTypes: 'array', verbose: true, strict: false });
ajv.compile(schema);
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.