Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmark/benchmark-from-msgpack-lite.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
// original: https://raw.githubusercontent.com/kawanet/msgpack-lite/master/lib/benchmark.js

var msgpack_msgpack = require("../src");
var msgpack_msgpack = require("../src/index.ts");

var msgpack_node = try_require("msgpack");
var msgpack_lite = try_require("msgpack-lite");
Expand Down
2 changes: 1 addition & 1 deletion benchmark/decode-string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import { utf8EncodeJs, utf8Count, utf8DecodeJs, utf8DecodeTD } from "../src/utils/utf8";
import { utf8EncodeJs, utf8Count, utf8DecodeJs, utf8DecodeTD } from "../src/utils/utf8.ts";

// @ts-ignore
import Benchmark from "benchmark";
Expand Down
2 changes: 1 addition & 1 deletion benchmark/encode-string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import { utf8EncodeJs, utf8Count, utf8EncodeTE } from "../src/utils/utf8";
import { utf8EncodeJs, utf8Count, utf8EncodeTE } from "../src/utils/utf8.ts";

// @ts-ignore
import Benchmark from "benchmark";
Expand Down
8 changes: 5 additions & 3 deletions benchmark/key-decoder.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/* eslint-disable no-console */
import { utf8EncodeJs, utf8Count, utf8DecodeJs } from "../src/utils/utf8";
import { utf8EncodeJs, utf8Count, utf8DecodeJs } from "../src/utils/utf8.ts";
import { CachedKeyDecoder } from "../src/CachedKeyDecoder.ts";

import data from "./benchmark-from-msgpack-lite-data.json" with { type: "json" };

// @ts-ignore
import Benchmark from "benchmark";
import { CachedKeyDecoder } from "../src/CachedKeyDecoder";

type InputType = {
bytes: Uint8Array;
byteLength: number;
str: string;
};

const keys: Array<InputType> = Object.keys(require("./benchmark-from-msgpack-lite-data.json")).map((str) => {
const keys: Array<InputType> = Object.keys(data).map((str) => {
const byteLength = utf8Count(str);
const bytes = new Uint8Array(new ArrayBuffer(byteLength));
utf8EncodeJs(str, bytes, 0);
Expand Down
1 change: 1 addition & 0 deletions benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@msgpack/msgpack-benchmark",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"update-dependencies": "npx rimraf node_modules/ package-lock.json ; npm install ; npm audit fix --force ; git restore package.json ; npm install"
},
Expand Down
2 changes: 1 addition & 1 deletion benchmark/profile-decode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { encode, decode, decodeAsync } from "../src";
import { encode, decode, decodeAsync } from "../src/index.ts";
// @ts-ignore
import _ from "lodash";
const data = require("./benchmark-from-msgpack-lite-data.json");
Expand Down
2 changes: 1 addition & 1 deletion benchmark/profile-encode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { encode } from "../src";
import { encode } from "../src/index.ts";
// @ts-ignore
import _ from "lodash";

Expand Down
2 changes: 1 addition & 1 deletion benchmark/string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import { encode, decode } from "../src";
import { encode, decode } from "../src/index.ts";

const ascii = "A".repeat(40000);
const emoji = "🌏".repeat(20000);
Expand Down
12 changes: 7 additions & 5 deletions benchmark/sync-vs-async.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!ts-node
#!/usr/bin/env node
/* eslint-disable no-console */

import { encode, decode, decodeAsync, decodeArrayStream } from "../src";
import { writeFileSync, unlinkSync, readFileSync, createReadStream } from "fs";
import { deepStrictEqual } from "assert";
import { encode, decode, decodeAsync, decodeArrayStream } from "../src/index.ts";
import { writeFileSync, unlinkSync, readFileSync, createReadStream } from "node:fs";
import { deepStrictEqual } from "node:assert";

type Data = { id: number; score: number; title: string; content: string; createdAt: Date };

(async () => {
const data = [];
const data: Data[] = [];
for (let i = 0; i < 1000; i++) {
const id = i + 1;
data.push({
Expand Down
2 changes: 1 addition & 1 deletion benchmark/timestamp-ext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { encode, decode } from "../src";
import { encode, decode } from "../src/index.ts";

const data = new Array(100).fill(new Date());

Expand Down