Skip to content

Commit

Permalink
add enwik8 test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangli20 committed Dec 8, 2023
1 parent c7f1a18 commit df438c4
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 30 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
target-branch: master
labels: [auto-dependencies]
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->

Closes #.

# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->

# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->

# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->

<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
65 changes: 65 additions & 0 deletions .github/workflows/delete_workflow_runs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Delete old workflow runs
on:
workflow_dispatch:
inputs:
days:
description: 'Days-worth of runs to keep for each workflow'
required: true
default: '30'
minimum_runs:
description: 'Minimum runs to keep for each workflow'
required: true
default: '6'
delete_workflow_pattern:
description: 'Name or filename of the workflow (if not set, all workflows are targeted)'
required: false
delete_workflow_by_state_pattern:
description: 'Filter workflows by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually'
required: true
default: "ALL"
type: choice
options:
- "ALL"
- active
- deleted
- disabled_inactivity
- disabled_manually
delete_run_by_conclusion_pattern:
description: 'Remove runs based on conclusion: action_required, cancelled, failure, skipped, success'
required: true
default: "ALL"
type: choice
options:
- "ALL"
- "Unsuccessful: action_required,cancelled,failure,skipped"
- action_required
- cancelled
- failure
- skipped
- success
dry_run:
description: 'Logs simulated changes, no deletions are performed'
required: false

jobs:
del_runs:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: ${{ github.event.inputs.days }}
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }}
delete_run_by_conclusion_pattern: >-
${{
startsWith(github.event.inputs.delete_run_by_conclusion_pattern, 'Unsuccessful:')
&& 'action_required,cancelled,failure,skipped'
|| github.event.inputs.delete_run_by_conclusion_pattern
}}
dry_run: ${{ github.event.inputs.dry_run }}
52 changes: 52 additions & 0 deletions .github/workflows/enwik8-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Enwik8 test

on:
workflow_dispatch:
push:
branches: ["master"]

jobs:
enwik8-test:
name: Enwik8 Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Build
run: cargo build --release

- name: Preparing enwik8
run: xz -d < test/enwik8.xz >enwik8

- name: Test with with enwik8
run: |
(time gzip < enwik8 >enwik8.gz) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >gzip.enc_time
(time gzip -d < enwik8.gz >enwik8.ungz) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >gzip.dec_time
(time bzip2 < enwik8 >enwik8.bz2) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >bzip2.enc_time
(time bzip2 -d < enwik8.bz2 >enwik8.unbz2) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >bzip2.dec_time
(time xz -6 < enwik8 >enwik8.xz) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >xz.enc_time
(time xz -d < enwik8.xz >enwik8.unxz) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >xz.dec_time
(time target/release/orz encode --silent -l0 < enwik8 >enwik8.orz0) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz0.enc_time
(time target/release/orz decode --silent < enwik8.orz0 >enwik8.unorz0) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz0.dec_time
(time target/release/orz encode --silent -l1 < enwik8 >enwik8.orz1) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz1.enc_time
(time target/release/orz decode --silent < enwik8.orz1 >enwik8.unorz1) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz1.dec_time
(time target/release/orz encode --silent -l2 < enwik8 >enwik8.orz2) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz2.enc_time
(time target/release/orz decode --silent < enwik8.orz2 >enwik8.unorz2) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz2.dec_time
cmp enwik8.unorz0 enwik8
cmp enwik8.unorz1 enwik8
cmp enwik8.unorz2 enwik8
- name: Test result
run: |
echo ""
printf "+---------+------------------+--------------+--------------+\n"
printf "| | %16s | %12s | %12s |\n" "Compressed Size" "Encode time" "Decode time"
printf "|---------+------------------+--------------+--------------|\n"
printf "| gzip | %16s | %12s | %12s |\n" "$(wc -c < enwik8.gz | grep -Poi '\d+')" "$(cat < gzip.enc_time)" "$(cat < gzip.dec_time)"
printf "| bzip2 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.bz2 | grep -Poi '\d+')" "$(cat < bzip2.enc_time)" "$(cat < bzip2.dec_time)"
printf "| orz -l0 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.orz0 | grep -Poi '\d+')" "$(cat < orz0.enc_time)" "$(cat < orz0.dec_time)"
printf "| orz -l1 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.orz1 | grep -Poi '\d+')" "$(cat < orz1.enc_time)" "$(cat < orz1.dec_time)"
printf "| orz -l2 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.orz2 | grep -Poi '\d+')" "$(cat < orz2.enc_time)" "$(cat < orz2.dec_time)"
printf "| xz -6 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.xz | grep -Poi '\d+')" "$(cat < xz.enc_time)" "$(cat < xz.dec_time)"
printf "+---------+------------------+--------------+--------------+\n"
22 changes: 0 additions & 22 deletions .github/workflows/rust.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,6 @@ pub unsafe extern "C" fn orz_decode_path(
#[no_mangle]
pub unsafe extern "C" fn orz_free_stat(ptr: *mut Stat) {
if !ptr.is_null() {
Box::from_raw(ptr);
let _ = Box::from_raw(ptr);
}
}
10 changes: 8 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ const SBVEC_PREMATCH_LEN: usize = LZ_BLOCK_SIZE / 2;
/// Encode the source into a target ORZ stream.
pub fn encode(source: &mut dyn Read, target: &mut dyn Write, cfg: &LZCfg) -> std::io::Result<Stat> {
let mut stat = Stat::default();
let mut lzenc = LZEncoder::default();

#[allow(unused_allocation)]
let sbvec = &mut Box::new([0u8; LZ_BLOCK_SIZE + SBVEC_SENTINEL_LEN])[..LZ_BLOCK_SIZE];
#[allow(unused_allocation)]
let tbvec = &mut Box::new([0u8; SBVEC_PREMATCH_LEN * 3]);
let mut lzenc = LZEncoder::default();

stat.target_size += write_version(target)? as u64;
loop {
Expand Down Expand Up @@ -154,9 +157,12 @@ pub fn encode(source: &mut dyn Read, target: &mut dyn Write, cfg: &LZCfg) -> std

pub fn decode(target: &mut dyn Read, source: &mut dyn Write) -> std::io::Result<Stat> {
let mut stat = Stat::default();
let mut lzdec = LZDecoder::default();

#[allow(unused_allocation)]
let sbvec = &mut Box::new([0u8; LZ_BLOCK_SIZE + SBVEC_SENTINEL_LEN])[..LZ_BLOCK_SIZE];
#[allow(unused_allocation)]
let tbvec = &mut Box::new([0u8; SBVEC_PREMATCH_LEN * 3]);
let mut lzdec = LZDecoder::default();

stat.target_size += check_version(target)? as u64;
let mut spos = SBVEC_PREMATCH_LEN;
Expand Down
Binary file added test/bible.txt.xz
Binary file not shown.
Binary file added test/enwik8.xz
Binary file not shown.

0 comments on commit df438c4

Please sign in to comment.