File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -491,3 +491,34 @@ mod tests {
491491 assert_eq ! ( url. domain( ) , None ) ;
492492 }
493493}
494+
495+ #[ cfg( bench) ]
496+ mod benches {
497+ use super :: * ;
498+ use crate :: test:: { black_box, Bencher } ;
499+
500+ const LOCAL_URL : & str = "ws://127.0.0.1:7777" ;
501+ const CLEARNET_URL : & str = "wss://relay.damus.io" ;
502+ const ONION_URL : & str = "ws://oxtrdevav64z64yb7x6rjg4ntzqjhedm5b5zjqulugknhzr46ny2qbad.onion" ;
503+
504+ #[ bench]
505+ pub fn parse_local_relay_url ( bh : & mut Bencher ) {
506+ bh. iter ( || {
507+ black_box ( RelayUrl :: parse ( LOCAL_URL ) ) . unwrap ( ) ;
508+ } ) ;
509+ }
510+
511+ #[ bench]
512+ pub fn parse_clearnet_relay_url ( bh : & mut Bencher ) {
513+ bh. iter ( || {
514+ black_box ( RelayUrl :: parse ( CLEARNET_URL ) ) . unwrap ( ) ;
515+ } ) ;
516+ }
517+
518+ #[ bench]
519+ pub fn parse_onion_relay_url ( bh : & mut Bencher ) {
520+ bh. iter ( || {
521+ black_box ( RelayUrl :: parse ( ONION_URL ) ) . unwrap ( ) ;
522+ } ) ;
523+ }
524+ }
You can’t perform that action at this time.
0 commit comments