Refactor TDLib facade and local time handling

This commit is contained in:
Mikhail Kilin
2026-05-17 17:58:29 +03:00
parent e09b83be69
commit 2e510dc932
38 changed files with 1025 additions and 862 deletions

View File

@@ -1,5 +1,7 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use tdlib_rs::enums::{TextEntity, TextEntityType};
use ratatui::style::Color;
use tdlib_rs::enums::TextEntityType;
use tdlib_rs::types::TextEntity;
use tele_tui::formatting::format_text_with_entities;
fn create_text_with_entities() -> (String, Vec<TextEntity>) {
@@ -9,27 +11,27 @@ fn create_text_with_entities() -> (String, Vec<TextEntity>) {
TextEntity {
offset: 8,
length: 4, // bold
type_: TextEntityType::Bold,
r#type: TextEntityType::Bold,
},
TextEntity {
offset: 17,
length: 6, // italic
type_: TextEntityType::Italic,
r#type: TextEntityType::Italic,
},
TextEntity {
offset: 34,
length: 4, // code
type_: TextEntityType::Code,
r#type: TextEntityType::Code,
},
TextEntity {
offset: 45,
length: 4, // link
type_: TextEntityType::Url,
r#type: TextEntityType::Url,
},
TextEntity {
offset: 54,
length: 7, // mention
type_: TextEntityType::Mention,
r#type: TextEntityType::Mention,
},
];
@@ -41,7 +43,9 @@ fn benchmark_format_simple_text(c: &mut Criterion) {
let entities = vec![];
c.bench_function("format_simple_text", |b| {
b.iter(|| format_text_with_entities(black_box(&text), black_box(&entities)));
b.iter(|| {
format_text_with_entities(black_box(&text), black_box(&entities), Color::White)
});
});
}
@@ -49,7 +53,9 @@ fn benchmark_format_markdown_text(c: &mut Criterion) {
let (text, entities) = create_text_with_entities();
c.bench_function("format_markdown_text", |b| {
b.iter(|| format_text_with_entities(black_box(&text), black_box(&entities)));
b.iter(|| {
format_text_with_entities(black_box(&text), black_box(&entities), Color::White)
});
});
}
@@ -67,13 +73,15 @@ fn benchmark_format_long_text(c: &mut Criterion) {
entities.push(TextEntity {
offset: start as i32,
length: format!("Word{}", i).len() as i32,
type_: TextEntityType::Bold,
r#type: TextEntityType::Bold,
});
}
}
c.bench_function("format_long_text_with_100_entities", |b| {
b.iter(|| format_text_with_entities(black_box(&text), black_box(&entities)));
b.iter(|| {
format_text_with_entities(black_box(&text), black_box(&entities), Color::White)
});
});
}