11use crate :: core:: error:: AnalysisError ;
22use crate :: net:: ProviderConfig ;
33use crate :: { core:: filter:: IntelligentFilter , net:: RemoteAnalyzer } ;
4+ use instant:: Instant ;
45use std:: collections:: HashMap ;
56use wasm_bindgen:: prelude:: * ;
67
@@ -51,8 +52,8 @@ impl Default for AnalysisOptions {
5152struct WASMDebugInfo {
5253 total_languages : usize ,
5354 total_files : usize ,
54- spend_time : u64 ,
5555 version : String ,
56+ spend_time : u64 ,
5657}
5758
5859#[ derive( serde:: Serialize ) ]
@@ -129,8 +130,8 @@ fn create_wasm_result(
129130 debug_info : WASMDebugInfo {
130131 total_languages : analysis. language_analyses . len ( ) ,
131132 total_files : analysis. global_metrics . file_count ,
132- spend_time,
133133 version : VERSION . to_string ( ) ,
134+ spend_time,
134135 } ,
135136 }
136137}
@@ -148,8 +149,8 @@ fn create_error_result(error: AnalysisError, url: String, spend_time: u64) -> WA
148149 debug_info : WASMDebugInfo {
149150 total_languages : 0 ,
150151 total_files : 0 ,
151- spend_time,
152152 version : VERSION . to_string ( ) ,
153+ spend_time,
153154 } ,
154155 }
155156}
@@ -159,8 +160,6 @@ pub async fn analyze_url(url: String, options: JsValue) -> Result<JsValue, JsVal
159160 let opts: AnalysisOptions = serde_wasm_bindgen:: from_value ( options) ?;
160161 console ( & format ! ( "Starting analysis for URL: {}" , url) ) ;
161162
162- let start_time = std:: time:: Instant :: now ( ) ;
163-
164163 let mut analyzer = RemoteAnalyzer :: new ( ) ;
165164 analyzer. set_global_config ( opts. to_provider_config ( ) ) ;
166165
@@ -172,6 +171,7 @@ pub async fn analyze_url(url: String, options: JsValue) -> Result<JsValue, JsVal
172171 } ,
173172 }
174173
174+ let start_time = Instant :: now ( ) ;
175175 let result = match analyzer. analyze_url ( & url) . await {
176176 Ok ( analysis) => {
177177 let result = create_wasm_result ( & analysis, start_time. elapsed ( ) . as_secs ( ) ) ;
0 commit comments