Lines 545-550
let rate2str v =
Link Here
|
545 |
" " |
545 |
" " |
546 |
end |
546 |
end |
547 |
|
547 |
|
|
|
548 |
let mib = 1024. *. 1024. |
549 |
let kib2str v = |
550 |
if v > 100_000_000. then |
551 |
Format.sprintf "%.0f MiB" (v /. mib) |
552 |
else if v > 1_000_000. then |
553 |
Format.sprintf "%.1f MiB" (v /. mib) |
554 |
else if v > 1024. then |
555 |
Format.sprintf "%.1f KiB" (v /. 1024.) |
556 |
else |
557 |
Format.sprintf "%.0f B" v |
558 |
|
548 |
let statistics () = |
559 |
let statistics () = |
549 |
let title = "Statistics" in |
560 |
let title = "Statistics" in |
550 |
let t = GWindow.dialog ~title () in |
561 |
let t = GWindow.dialog ~title () in |
Lines 559-580
let statistics () =
Link Here
|
559 |
let reception = new stats 320 50 in |
570 |
let reception = new stats 320 50 in |
560 |
t#vbox#pack ~expand:false ~padding:4 (reception :> GObj.widget); |
571 |
t#vbox#pack ~expand:false ~padding:4 (reception :> GObj.widget); |
561 |
|
572 |
|
562 |
let lst = |
573 |
let cols = new GTree.column_list in |
563 |
GList.clist |
574 |
let c_1 = cols#add Gobject.Data.string in |
564 |
~packing:(t#vbox#add) |
575 |
let c_client = cols#add Gobject.Data.string in |
565 |
~titles_active:false |
576 |
let c_server = cols#add Gobject.Data.string in |
566 |
~titles:[""; "Client"; "Server"; "Total"] () |
577 |
let c_total = cols#add Gobject.Data.string in |
567 |
in |
578 |
let lst = GTree.list_store cols in |
568 |
lst#set_column ~auto_resize:true 0; |
579 |
let l = GTree.view ~model:lst ~enable_search:false ~packing:(t#vbox#add) () in |
569 |
lst#set_column ~auto_resize:true ~justification:`RIGHT 1; |
580 |
l#selection#set_mode `NONE; |
570 |
lst#set_column ~auto_resize:true ~justification:`RIGHT 2; |
581 |
ignore (l#append_column (GTree.view_column ~title:"" |
571 |
lst#set_column ~auto_resize:true ~justification:`RIGHT 3; |
582 |
~renderer:(GTree.cell_renderer_text [], ["text", c_1]) ())); |
572 |
ignore (lst#append ["Reception rate"]); |
583 |
ignore (l#append_column (GTree.view_column ~title:"Client" |
573 |
ignore (lst#append ["Data received"]); |
584 |
~renderer:(GTree.cell_renderer_text [`XALIGN 1.0], ["text", c_client]) ())); |
574 |
ignore (lst#append ["File data written"]); |
585 |
ignore (l#append_column (GTree.view_column ~title:"Server" |
575 |
for r = 0 to 2 do |
586 |
~renderer:(GTree.cell_renderer_text [`XALIGN 1.0], ["text", c_server]) ())); |
576 |
lst#set_row ~selectable:false r |
587 |
ignore (l#append_column (GTree.view_column ~title:"Total" |
577 |
done; |
588 |
~renderer:(GTree.cell_renderer_text [`XALIGN 1.0], ["text", c_total]) ())); |
|
|
589 |
let rate_row = lst#append () in |
590 |
ignore (lst#set rate_row c_1 "Reception rate"); |
591 |
let receive_row = lst#append () in |
592 |
ignore (lst#set receive_row c_1 "Data received"); |
593 |
let data_row = lst#append () in |
594 |
ignore (lst#set data_row c_1 "File data written"); |
578 |
|
595 |
|
579 |
ignore (t#event#connect#map ~callback:(fun _ -> |
596 |
ignore (t#event#connect#map ~callback:(fun _ -> |
580 |
emission#activate true; |
597 |
emission#activate true; |
Lines 597-615
let statistics () =
Link Here
|
597 |
let stopCounter = ref 0 in |
614 |
let stopCounter = ref 0 in |
598 |
|
615 |
|
599 |
let updateTable () = |
616 |
let updateTable () = |
600 |
let kib2str v = Format.sprintf "%.0f B" v in |
617 |
let row = rate_row in |
601 |
lst#set_cell ~text:(rate2str !receiveRate2) 0 1; |
618 |
lst#set ~row ~column:c_client (rate2str !receiveRate2); |
602 |
lst#set_cell ~text:(rate2str !emitRate2) 0 2; |
619 |
lst#set ~row ~column:c_server (rate2str !emitRate2); |
603 |
lst#set_cell ~text: |
620 |
lst#set ~row ~column:c_total (rate2str (!receiveRate2 +. !emitRate2)); |
604 |
(rate2str (!receiveRate2 +. !emitRate2)) 0 3; |
621 |
let row = receive_row in |
605 |
lst#set_cell ~text:(kib2str !receivedBytes) 1 1; |
622 |
lst#set ~row ~column:c_client (kib2str !receivedBytes); |
606 |
lst#set_cell ~text:(kib2str !emittedBytes) 1 2; |
623 |
lst#set ~row ~column:c_server (kib2str !emittedBytes); |
607 |
lst#set_cell ~text: |
624 |
lst#set ~row ~column:c_total (kib2str (!receivedBytes +. !emittedBytes)); |
608 |
(kib2str (!receivedBytes +. !emittedBytes)) 1 3; |
625 |
let row = data_row in |
609 |
lst#set_cell ~text:(kib2str !clientWritten) 2 1; |
626 |
lst#set ~row ~column:c_client (kib2str !clientWritten); |
610 |
lst#set_cell ~text:(kib2str !serverWritten) 2 2; |
627 |
lst#set ~row ~column:c_server (kib2str !serverWritten); |
611 |
lst#set_cell ~text: |
628 |
lst#set ~row ~column:c_total (kib2str (!clientWritten +. !serverWritten)) |
612 |
(kib2str (!clientWritten +. !serverWritten)) 2 3 |
|
|
613 |
in |
629 |
in |
614 |
let timeout _ = |
630 |
let timeout _ = |
615 |
emitRate := |
631 |
emitRate := |