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

Feat/benchmark #273

Merged
merged 5 commits into from
Jun 5, 2024
Merged

Feat/benchmark #273

merged 5 commits into from
Jun 5, 2024

Conversation

JackWang032
Copy link
Collaborator

@JackWang032 JackWang032 commented Mar 19, 2024

Support benchmark for all languages

使用

运行基准测试命令

 pnpm run benchmark

终端中选择对应需要基准性能测试的SQL语言

配置信息

在benchmark/run.ts中维护配置信息

type TestFile = {
    /** Benchmark Name */
    name: string;
    /** Test sql name */
    sqlFileName: string;
    /** Test run times */
    loopTimes?: number;
    /** Test method name of parser */
    testTypes: string[];
    /** Exclude languages */
    excludes?: Language[];
    /** Include languages */
    includes?: Language[];
};

const testFiles: TestFile[] = [
    {
        name: 'Query Collection (100 Rows)',
        sqlFileName: 'select.sql',
        loopTimes: 3,
        testTypes: ['validate', 'getAllTokens'],
        excludes: ['plsql', 'postgresql'],
    },
    {
        name: 'Select All Entities',
        sqlFileName: 'select.sql',
        loopTimes: 1,
        testTypes: ['getAllEntities'],
        includes: ['hive'],
    },
    {
        name: 'Create Table (100 Rows)',
        sqlFileName: 'create.sql',
        loopTimes: 3,
        testTypes: ['validate', 'getAllTokens'],
        excludes: ['plsql', 'postgresql'],
    },
];

注意点

默认对testTypes中的方法传入的参数为对应语言的sql字符串,如需自定义参数,在/benchmark/data/目录下新建params.json文件进行配置,如需取默认的sql参数,则可传入$sql,可参考如下

{
    "create": {
        "validate": ["$sql"],
        "getAllTokens": ["$sql"],
        "getAllEntities": ["$sql", { "lineNumber": 8, "column": 1 }]
    },
    "select": {
        "validate": ["$sql"],
        "getAllTokens": ["$sql"],
        "getAllEntities": ["$sql", { "lineNumber": 8, "column": 1 }]
    }
}

image

运行结果

image

默认不保存每次的测试结果,测试结果信息会保存在/benchmark/reports/xxx.benchmark.md,以下是一次结果案例
image

@HaydenOrz
Copy link
Collaborator

#247

@JackWang032
Copy link
Collaborator Author

@HaydenOrz @liuxy0551 新增了传入参数方式,看下是否符合场景

@HaydenOrz HaydenOrz merged commit de1bd9d into DTStack:main Jun 5, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants