Refactor TDLib facade and local time handling
This commit is contained in:
@@ -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)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ fn create_test_messages(count: usize) -> Vec<tele_tui::tdlib::MessageInfo> {
|
||||
(0..count)
|
||||
.map(|i| {
|
||||
let builder = MessageBuilder::new(MessageId::new(i as i64))
|
||||
.sender_name(&format!("User{}", i % 10))
|
||||
.text(&format!(
|
||||
.sender_name(format!("User{}", i % 10))
|
||||
.text(format!(
|
||||
"Test message number {} with some longer text to make it more realistic",
|
||||
i
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user