1 (* Copyright (C) 2004-2005, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
31 Helm_registry.set "getter.mode" "remote";
32 Helm_registry.set "getter.url" "http://mowgli.cs.unibo.it:58081/"
34 let body_RE = Str.regexp "^.*\\.body$"
35 let con_RE = Str.regexp "^.*\\.con$"
38 if Sys.file_exists f then
41 let rec parse uri tmpfile1 tmpfile2 =
42 (*prerr_endline (sprintf "%s %s" tmpfile1 (match tmpfile2 with None -> "None" | Some f -> "Some " ^ f));*)
44 let uri' = UriManager.uri_of_string uri in
45 let time_new0 = Unix.gettimeofday () in
46 (* let obj_new = CicPushParser.CicParser.annobj_of_xml tmpfile1 tmpfile2 in*)
47 let obj_new = CicParser.annobj_of_xml uri' tmpfile1 tmpfile2 in
48 let time_new1 = Unix.gettimeofday () in
50 let time_old0 = Unix.gettimeofday () in
51 ignore (Unix.system (sprintf "gunzip -c %s > test.tmp && mv test.tmp %s"
55 ignore (Unix.system (sprintf "gunzip -c %s > test.tmp && mv test.tmp %s"
58 let obj_old = CicPxpParser.CicParser.annobj_of_xml uri' tmpfile1 tmpfile2 in
59 let time_old1 = Unix.gettimeofday () in
61 let time_old = time_old1 -. time_old0 in
62 let time_new = time_new1 -. time_new0 in
63 let are_equal = (obj_old = obj_new) in
64 printf "%s\t%b\t%f\t%f\t%f\n"
65 uri are_equal time_old time_new (time_new /. time_old *. 100.);
68 | CicParser.Getter_failure ("key_not_found", uri)
69 when Str.string_match body_RE uri 0 ->
70 parse uri tmpfile1 None
71 | CicParser.Parser_failure msg ->
72 printf "%s FAILED (%s)\n" uri msg; flush stdout)
77 let uri = input_line stdin in
78 let tmpfile1 = Http_getter.getxml uri in
80 if Str.string_match con_RE uri 0 then begin
81 Some (Http_getter.getxml (uri ^ ".body"))
85 parse uri tmpfile1 tmpfile2
87 with End_of_file -> ()