mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-11-16 08:10:41 +08:00
The aim of this commit is to better represent the reference names using git-ref-format. The first places to change were the Branch and Tag types. For Branch, the previous types were simply wrappers around the names. They stay this way, using RefString instead. For Tag, the `name` field is replaced with RefString. Note: The parsing logic becomes easier here by utilising the Namespaced and Qualified types. The consequences of these changes meant that areas that used BranchName or TagName are changed to use RefString. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
46 lines
1.6 KiB
Rust
46 lines
1.6 KiB
Rust
// This file is part of radicle-surf
|
|
// <https://github.com/radicle-dev/radicle-surf>
|
|
//
|
|
// Copyright (C) 2019-2020 The Radicle Team <dev@radicle.xyz>
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License version 3 or
|
|
// later as published by the Free Software Foundation.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
|
use git_ref_format::refname;
|
|
use radicle_surf::{
|
|
file_system::{unsound, Path},
|
|
git::{Branch, Repository},
|
|
};
|
|
|
|
fn last_commit_comparison(c: &mut Criterion) {
|
|
let repo = Repository::open("./data/git-platinum")
|
|
.expect("Could not retrieve ./data/git-platinum as git repository");
|
|
let rev = Branch::local(refname!("master"));
|
|
|
|
let mut group = c.benchmark_group("Last Commit");
|
|
for path in [
|
|
Path::root(),
|
|
unsound::path::new("~/src/memory.rs"),
|
|
unsound::path::new("~/this/is/a/really/deeply/nested/directory/tree"),
|
|
]
|
|
.iter()
|
|
{
|
|
group.bench_with_input(BenchmarkId::new("", path), path, |b, path| {
|
|
b.iter(|| repo.as_ref().last_commit(path.clone(), &rev))
|
|
});
|
|
}
|
|
}
|
|
|
|
criterion_group!(benches, last_commit_comparison);
|
|
criterion_main!(benches);
|