| 1 | % (c) 2020-2026 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, | |
| 2 | % Heinrich Heine Universitaet Duesseldorf | |
| 3 | % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) | |
| 4 | ||
| 5 | :- module(tools_fastread, [ read_term_from_stream/2, | |
| 6 | read_term_from_string/2, | |
| 7 | read_test/1, tok_test/1, | |
| 8 | fastrw_read/3, | |
| 9 | reset_line_nr/0 | |
| 10 | ]). | |
| 11 | ||
| 12 | :- use_module(module_information,[module_info/2]). | |
| 13 | ||
| 14 | :- module_info(group,infrastructure). | |
| 15 | :- module_info(description,'This module provides a more efficient way to parse and read large Prolog terms.'). | |
| 16 | ||
| 17 | :- use_module(self_check). | |
| 18 | :- use_module(error_manager,[add_error/3]). | |
| 19 | ||
| 20 | ||
| 21 | :- use_module(error_manager). | |
| 22 | ||
| 23 | ||
| 24 | :- use_module(library(fastrw),[fast_read/2]). | |
| 25 | % this reads terms in binary format | |
| 26 | fastrw_read(S,Term,Error) :- | |
| 27 | catch( fast_read(S,Term1), % from library fastrw | |
| 28 | error(E,_), | |
| 29 | ( E=syntax_error(_) -> Error = true | |
| 30 | ; E=permission_error(_,_,_) -> Term1 = end_of_file | |
| 31 | ; E=consistency_error(_,_,_) | |
| 32 | -> add_error(tools_fastread,'Consistency error when reading from stream: ',E), | |
| 33 | Error = true | |
| 34 | ; | |
| 35 | add_error(tools_fastread,'Unknown error when reading from stream: ',E), | |
| 36 | throw(E)) | |
| 37 | ), | |
| 38 | Term1 = Term. | |
| 39 | ||
| 40 | ||
| 41 | ||
| 42 | ||
| 43 | :- set_prolog_flag(double_quotes, codes). | |
| 44 | ||
| 45 | % Limitations: | |
| 46 | % - only prefix notation and lists supported | |
| 47 | % - supports atoms with and without quotes, in quotes one can use octal and hex literals and backslash escaping | |
| 48 | % - no support for variables (yet?) | |
| 49 | % - no support for operator declarations | |
| 50 | % - should work with numbers (integers and floats) | |
| 51 | % - no real support for (a,b) terms using , as infix | |
| 52 | % - no support for block comments | |
| 53 | ||
| 54 | ||
| 55 | % -------------------- | |
| 56 | ||
| 57 | % Tokeniser | |
| 58 | ||
| 59 | ||
| 60 | :- use_module(tools,[print_memory_used_wo_gc/0]). | |
| 61 | tok_read(File) :- statistics(walltime,_), | |
| 62 | %open(File,read,Stream1),reset_line_nr, repeat, get_code(Stream1,C), C = -1,!, close(Stream1), | |
| 63 | %statistics(walltime,[_,W1]), format('~n% Walltime ~w ms to get_codes ~w~n',[W1,File]), | |
| 64 | open(File,read,Stream),reset_line_nr, | |
| 65 | read_tokens(Stream),close(Stream), | |
| 66 | statistics(walltime,[_,W2]), format('~n% Walltime ~w ms to tokenise ~w~n',[W2,File]), | |
| 67 | print_memory_used_wo_gc. | |
| 68 | ||
| 69 | % set_prolog_flag(profiling,on) | |
| 70 | tok_test(1) :- | |
| 71 | tok_read('../prob_examples/public_examples/B/Demo/Bakery0.prob'). | |
| 72 | tok_test(2) :- | |
| 73 | tok_read('../prob_examples/public_examples/B/Benchmarks/CAN_BUS_tlc.prob'). | |
| 74 | tok_test(3) :- | |
| 75 | tok_read('../prob_examples/public_examples/B/PerformanceTests/Generated/Generated4000.prob'). | |
| 76 | tok_test(4) :- | |
| 77 | tok_read('../prob_examples/public_examples/B/PerformanceTests/Generated/Generated10000.prob'). | |
| 78 | tok_test(7) :- | |
| 79 | tok_read('../private_examples/ClearSy/2019_Nov/rule_perf4/rule_split.prob'). | |
| 80 | ||
| 81 | read_tokens(Stream) :- | |
| 82 | get_next_token(Stream,Tok), % print_token(Tok), | |
| 83 | !, | |
| 84 | (Tok = eof -> true | |
| 85 | ; read_tokens(Stream)). | |
| 86 | read_tokens(Stream) :- | |
| 87 | get_code(Stream,C), | |
| 88 | format(user_error,'Could not process: ~w~n',[C]). | |
| 89 | ||
| 90 | %print_token(atom(L)) :- !, format('Token: Atom ~s~n',[L]). | |
| 91 | %print_token(S) :- !, format('Token: ~w~n',[S]). | |
| 92 | ||
| 93 | % get next Prolog token from a stream | |
| 94 | % TO DO: produce a version without peek, which returns first code following token | |
| 95 | get_next_token(Stream,Token) :- get_code(Stream,C), !, | |
| 96 | get_next_token1(C,Stream,Token). | |
| 97 | ||
| 98 | ||
| 99 | get_next_token1(-1,_,eof). | |
| 100 | get_next_token1(32,Stream,Token) :- !, get_next_token(Stream,Token). | |
| 101 | get_next_token1(10,Stream,Token) :- !, inc_line_nr, get_next_token(Stream,Token). | |
| 102 | get_next_token1(13,Stream,Token) :- !, get_next_token(Stream,Token). | |
| 103 | get_next_token1(0'(,_,open_paren). % adding a cut here seems to degrade performance, but leads to backtracking | |
| 104 | get_next_token1(0'),_,close_paren). | |
| 105 | get_next_token1(0'[,_,open_bracket). | |
| 106 | get_next_token1(0'],_,close_bracket). | |
| 107 | get_next_token1(0',,_,comma). | |
| 108 | get_next_token1(0'.,_,dot). | |
| 109 | get_next_token1(39,Stream,atom(T)) :- !, get_quoted_atom_codes(Stream,T). | |
| 110 | get_next_token1(0'%,Stream,Token) :- !, % line comment | |
| 111 | skip_until_end_of_line(Stream),!,get_next_token(Stream,Token). | |
| 112 | get_next_token1(X,Stream,number([X|T])) :- is_digit(X),!, get_number_codes(Stream,T). | |
| 113 | get_next_token1(X,Stream,atom([X|T])) :- is_lowcase(X),!, get_atom_codes(Stream,T). | |
| 114 | get_next_token1(X,_,_) :- | |
| 115 | \+ is_token_code(X), % the clauses above have no cut (for performance); avoid spurious errors on backtracking | |
| 116 | prolog_code_error(X),fail. | |
| 117 | ||
| 118 | % codes handled by the clauses of get_next_token1 without cut | |
| 119 | is_token_code(-1). | |
| 120 | is_token_code(0'(). | |
| 121 | is_token_code(0')). | |
| 122 | is_token_code(0'[). | |
| 123 | is_token_code(0']). | |
| 124 | is_token_code(0',). | |
| 125 | is_token_code(0'.). | |
| 126 | ||
| 127 | get_number_codes(Stream,[H|T]) :- peek_code(Stream,H), is_digit(H), | |
| 128 | !, get_code(Stream,_), get_number_codes(Stream,T). | |
| 129 | get_number_codes(_,[]). | |
| 130 | % TO DO: also accept floats | |
| 131 | ||
| 132 | get_atom_codes(Stream,[H|T]) :- | |
| 133 | peek_code(Stream,H), is_unquoted_atom_letter(H),!, | |
| 134 | get_code(Stream,_), get_atom_codes(Stream,T). | |
| 135 | get_atom_codes(_,[]). | |
| 136 | ||
| 137 | get_quoted_atom_codes(Stream,Res) :- get_code(Stream,H), | |
| 138 | ( H = 92 -> get_code(Stream,H2), % backslash: read next code and treat it specially | |
| 139 | treat_escaped_code(H2,Stream,Res) | |
| 140 | ; H = 39 -> Res=[] | |
| 141 | ; H = -1 -> format(user_error,'Unterminated quoted atom~n',[]), prolog_token_error(end_of_file), fail | |
| 142 | ; Res=[H|T], get_quoted_atom_codes(Stream,T)). | |
| 143 | ||
| 144 | skip_until_end_of_line(Stream) :- get_code(Stream,H), | |
| 145 | (H = 10 -> inc_line_nr | |
| 146 | ; H = -1 -> format(user_error,'Unterminated % comment~n',[]), prolog_token_error(H), fail | |
| 147 | ; skip_until_end_of_line(Stream)). | |
| 148 | ||
| 149 | % see page 60, Section 4.1.7.6 Escape Sequences in SICStus Prolog manual | |
| 150 | treat_escaped_code(Code,Stream,[NewCode|T]) :- escape_conversion(Code,NewCode),!, | |
| 151 | get_quoted_atom_codes(Stream,T). | |
| 152 | treat_escaped_code(Octal,Stream,[OctResult|T]) :- is_octal_digit(Octal,Nr),!, % treat chars like \374\ | |
| 153 | get_code(Stream,NxtCode), | |
| 154 | get_octal_codes(NxtCode,Stream,Nr,OctResult), | |
| 155 | get_quoted_atom_codes(Stream,T). | |
| 156 | treat_escaped_code(0'x,Stream,[HexResult|T]) :- !, % treat chars like \x21D4\ | |
| 157 | get_code(Stream,NxtCode), | |
| 158 | get_hex_codes(NxtCode,Stream,0,HexResult), | |
| 159 | get_quoted_atom_codes(Stream,T). | |
| 160 | treat_escaped_code(10,Stream,T) :- !, %\LFD ignored ; TO DO: also support 13 | |
| 161 | get_quoted_atom_codes(Stream,T). | |
| 162 | treat_escaped_code(-1,_,_) :- !, format(user_error,'Unterminated quoted atom ending with backslash at: ~w~n',[end_of_file]),fail. | |
| 163 | treat_escaped_code(X,_,_) :- prolog_code_error('escape sequence',X),fail. | |
| 164 | ||
| 165 | escape_conversion(39,39). % single quote ' | |
| 166 | escape_conversion(34,34). % double quote " | |
| 167 | escape_conversion(92,92). | |
| 168 | escape_conversion(0'n,10). | |
| 169 | escape_conversion(0't,9). | |
| 170 | escape_conversion(0'b,8). | |
| 171 | escape_conversion(0'r,13). | |
| 172 | ||
| 173 | ||
| 174 | get_octal_codes(H,Stream,Acc,Res) :- is_octal_digit(H,HNr), | |
| 175 | !, A2 is Acc*8+HNr, | |
| 176 | get_code(Stream,NxtCode), get_octal_codes(NxtCode,Stream,A2,Res). | |
| 177 | get_octal_codes(92,_,Acc,Res) :- !, Res=Acc. | |
| 178 | get_octal_codes(X,_,_,_) :- prolog_code_error('octal literal',X),fail. | |
| 179 | ||
| 180 | get_hex_codes(H,Stream,Acc,Res) :- is_hex_digit(H,HNr), | |
| 181 | !, A2 is Acc*16+HNr, | |
| 182 | get_code(Stream,NxtCode), get_hex_codes(NxtCode,Stream,A2,Res). | |
| 183 | get_hex_codes(92,_,Acc,Res) :- !, Res=Acc. | |
| 184 | get_hex_codes(X,_,_,_) :- prolog_code_error('hex literal',X),fail. | |
| 185 | ||
| 186 | ||
| 187 | ||
| 188 | % 45 = leading minus sign | |
| 189 | is_digit(X) :- X=45 ; (X>=48, X=<57). | |
| 190 | ||
| 191 | :- assert_must_succeed(tools_fastread:is_octal_digit(0'7,7)). | |
| 192 | is_octal_digit(X,Nr) :- X>=48, X=<55, Nr is X-48. | |
| 193 | :- assert_must_succeed(tools_fastread:is_hex_digit(0'f,15)). | |
| 194 | :- assert_must_succeed(tools_fastread:is_hex_digit(0'F,15)). | |
| 195 | :- assert_must_succeed(tools_fastread:is_hex_digit(0'9,9)). | |
| 196 | is_hex_digit(X,Nr) :- X>=48, X=<57, Nr is X-48. | |
| 197 | is_hex_digit(X,Nr) :- X>=65, X=<70, Nr is X-55. % upper-case A-F | |
| 198 | is_hex_digit(X,Nr) :- X>=97, X=<102, Nr is X-87. % lower-case a-f | |
| 199 | is_lowcase(X) :- X>=97, X=<122. | |
| 200 | ||
| 201 | is_unquoted_atom_letter(X) :- X>=97, X=<122. | |
| 202 | is_unquoted_atom_letter(X) :- X>=65, X=<90. | |
| 203 | is_unquoted_atom_letter(X) :- X=95. | |
| 204 | is_unquoted_atom_letter(X) :- X>=48, X=<57. | |
| 205 | ||
| 206 | %is_quoted_atom_letter(X) :- X \= 39. %, X \=10, X \=13. | |
| 207 | ||
| 208 | % skip over whitespace and return code after whitspace (peeked) | |
| 209 | skip_ws(Stream,NextCode) :- peek_code(Stream,C), | |
| 210 | (is_skip_whitespace(C) -> get_code(Stream,_),skip_ws(Stream,NextCode) | |
| 211 | ; NextCode=C). | |
| 212 | ||
| 213 | is_skip_whitespace(32). | |
| 214 | is_skip_whitespace(10) :- inc_line_nr. | |
| 215 | is_skip_whitespace(13). | |
| 216 | ||
| 217 | % ------------------------ | |
| 218 | ||
| 219 | expect_token(Stream,ETok) :- get_next_token(Stream,RTok),!, | |
| 220 | (RTok = ETok -> true | |
| 221 | ; cur_line(L), | |
| 222 | format(user_error,'Unexpected token on line ~w: ~w, expected ~w~n',[L,RTok,ETok]), | |
| 223 | fail). | |
| 224 | ||
| 225 | prolog_token_error(Tok) :- cur_line(L), | |
| 226 | %format(user_error,'Unexpected token on line ~w: ~w~n',[L,Tok]), | |
| 227 | add_error(fastread,'Unexpected token on line:',Tok:L). | |
| 228 | prolog_code_error(Code) :- cur_line(L), code_desc(Code,Desc), | |
| 229 | format(user_error,'Unexpected character on line ~w: ~w ~w~n',[L,Code,Desc]), | |
| 230 | add_error(fastread,'Unexpected character code on line:',Code:line(L)). | |
| 231 | prolog_code_error(Kind,Code) :- cur_line(L), code_desc(Code,Desc), | |
| 232 | format(user_error,'Unexpected character for ~w on line ~w: ~w ~w~n',[Kind,L,Code,Desc]), | |
| 233 | add_error(fastread,'Unexpected character code on line:',Kind:Code:line(L)). | |
| 234 | ||
| 235 | code_desc(-1,Desc) :- !, Desc = '(end of file)'. % -1 cannot be printed with ~s | |
| 236 | code_desc(Code,Desc) :- atom_codes(Desc,[0'",Code,0'"]). | |
| 237 | ||
| 238 | :- dynamic cur_line/1. | |
| 239 | cur_line(1). | |
| 240 | inc_line_nr :- retract(cur_line(N)), N1 is N+1, assertz(cur_line(N1)). | |
| 241 | % has to be called before reading a new file or string, otherwise line numbers in error messages accumulate | |
| 242 | reset_line_nr :- retractall(cur_line(_)), assertz(cur_line(1)). | |
| 243 | ||
| 244 | % ------------------------ | |
| 245 | ||
| 246 | :- assert_must_succeed(tools_fastread:read_term_from_string("atom('a',1,2).",atom(a,1,2))). | |
| 247 | :- assert_must_succeed(tools_fastread:read_term_from_string("'\\''.",'\'')). | |
| 248 | :- assert_must_succeed(tools_fastread:read_term_from_string("'\\374\\'.",'\374\')). | |
| 249 | ||
| 250 | % truncated input must fail with an error message (not raise an exception) | |
| 251 | :- assert_must_succeed((\+ tools_fastread:read_term_from_string("f(",_), error_manager:clear_errors_with_source(fastread))). | |
| 252 | :- assert_must_succeed((\+ tools_fastread:read_term_from_string("f(a,",_), error_manager:clear_errors_with_source(fastread))). | |
| 253 | :- assert_must_succeed((\+ tools_fastread:read_term_from_string("m(p3(1,1",_), error_manager:clear_errors_with_source(fastread))). | |
| 254 | :- assert_must_succeed((\+ tools_fastread:read_term_from_string("[",_), error_manager:clear_errors_with_source(fastread))). | |
| 255 | % line numbers are counted per string | |
| 256 | :- assert_must_succeed((tools_fastread:read_term_from_string("f(\n\na).",_), tools_fastread:read_term_from_string("g.",_), | |
| 257 | tools_fastread:cur_line(1))). | |
| 258 | ||
| 259 | :- use_module(library(codesio),[open_codes_stream/2]). | |
| 260 | read_term_from_string(Codes,Term) :- | |
| 261 | reset_line_nr, | |
| 262 | open_codes_stream(Codes,Stream), | |
| 263 | read_term_from_stream(Stream,Term), | |
| 264 | close(Stream). | |
| 265 | ||
| 266 | ||
| 267 | % read next term on stream, term has to be followed by '.' | |
| 268 | read_term_from_stream(Stream,Term) :- | |
| 269 | get_next_token(Stream,Token),!, | |
| 270 | get_next_term(Token,Stream,Term),!, | |
| 271 | (Term='end_of_file' -> true | |
| 272 | ; expect_token(Stream,dot)). | |
| 273 | ||
| 274 | % get one term, without dot at end: | |
| 275 | get_next_term(eof,_,'end_of_file'). | |
| 276 | get_next_term(number(C),_,Term) :- number_codes(Term,C). | |
| 277 | get_next_term(atom(C),Stream,Term) :- atom_codes(Atom,C), complete_atom(Atom,Stream,Term). | |
| 278 | get_next_term(open_bracket,Stream,List) :- get_term_list(Stream,close_bracket,List). | |
| 279 | get_next_term(open_paren,Stream,'$pair'(List)) :- get_term_list(Stream,close_paren,List). | |
| 280 | get_next_term(close_paren,_,_) :- prolog_token_error(close_paren),fail. | |
| 281 | get_next_term(close_bracket,_,_) :- prolog_token_error(close_bracket),fail. | |
| 282 | get_next_term(comma,_,_) :- prolog_token_error(comma),fail. | |
| 283 | get_next_term(dot,_,_) :- prolog_token_error(dot),fail. | |
| 284 | ||
| 285 | % get a term which is an argument or list element: end of file is not allowed here | |
| 286 | get_next_arg_term(eof,_,_) :- !, prolog_token_error(end_of_file), fail. | |
| 287 | get_next_arg_term(Token,Stream,Term) :- get_next_term(Token,Stream,Term). | |
| 288 | ||
| 289 | % check if an atom is followed by a list of arguments (Term1,...) | |
| 290 | complete_atom(Atom,Stream,Term) :- skip_ws(Stream,C), C==0'(, !, | |
| 291 | get_code(Stream,_), | |
| 292 | % TO DO: special case for binary operators like conjunct, transform into flat list (associativity holds) meaning we can get tail-recursion | |
| 293 | get_term_list(Stream,close_paren,List), | |
| 294 | Term =.. [Atom|List]. | |
| 295 | complete_atom(Atom,_,Atom). % atom without parentheses, i.e., on its own | |
| 296 | ||
| 297 | % pre-construct term for certain functors to make above call tail-recursive | |
| 298 | % however, as conjunctions are often stored the other way conjunct(pos,conjunct(...),Pred) this is not really beneficial | |
| 299 | % we could have a special get_conjunct which creates a list | |
| 300 | known_arity(empty_set,empty_set(Pos),[Pos]). | |
| 301 | known_arity(boolean_true,boolean_true(Pos),[Pos]). | |
| 302 | known_arity(boolean_false,boolean_false(Pos),[Pos]). | |
| 303 | known_arity(identifier,identifier(Pos,ID),[Pos,ID]). | |
| 304 | known_arity(integer,integer(Pos,I),[Pos,I]). | |
| 305 | known_arity(string,string(Pos,I),[Pos,I]). | |
| 306 | known_arity(equal,equal(Pos,A,B),[Pos,A,B]). | |
| 307 | known_arity(not_equal,not_equal(Pos,A,B),[Pos,A,B]). | |
| 308 | %known_arity(couple,couple(Pos,A,B),[Pos,A,B]). % couple(Pos,List) | |
| 309 | known_arity(couple,couple(Pos,L),[Pos,L]). | |
| 310 | known_arity(set_extension,set_extension(Pos,L),[Pos,L]). | |
| 311 | known_arity(sequence_extension,sequence_extension(Pos,L),[Pos,L]). | |
| 312 | known_arity(conjunct,conjunct(Pos,A,B),[Pos,A,B]). | |
| 313 | known_arity(disjunct,disjunct(Pos,A,B),[Pos,A,B]). | |
| 314 | known_arity(interval,interval(Pos,A,B),[Pos,A,B]). | |
| 315 | known_arity(member,member(Pos,A,B),[Pos,A,B]). | |
| 316 | known_arity(function,function(Pos,A,B),[Pos,A,B]). | |
| 317 | known_arity(assign,assign(Pos,A,B),[Pos,A,B]). | |
| 318 | known_arity(p3,p3(A,B,C),[A,B,C]). | |
| 319 | known_arity(p4,p4(A,B,C,D),[A,B,C,D]). | |
| 320 | known_arity(p5,p5(A,B,C,D,E),[A,B,C,D,E]). | |
| 321 | ||
| 322 | % get list of terms separated by , and terminated by provided token | |
| 323 | get_term_list(Stream,EndToken,List) :- get_next_token(Stream,Token), get_term_list_aux(Token,Stream,EndToken,List). | |
| 324 | ||
| 325 | get_term_list_aux(EndToken,_,EndToken,List) :- !, List=[]. | |
| 326 | get_term_list_aux(Token,Stream,EndToken,[Term1|TList]) :- get_next_arg_term(Token,Stream,Term1), | |
| 327 | get_next_token(Stream,Token2),!, | |
| 328 | get_term_list_aux2(Token2,Stream,EndToken,TList). | |
| 329 | ||
| 330 | get_term_list_aux2(EndToken,_,EndToken,List) :- !, List=[]. | |
| 331 | get_term_list_aux2(comma,Stream,EndToken,[Term1|TList]) :- !, % the error clause below is only for other tokens | |
| 332 | get_next_token(Stream,Token1), | |
| 333 | get_next_arg_term(Token1,Stream,Term1),!, | |
| 334 | get_next_token(Stream,Token2), | |
| 335 | get_term_list_aux2(Token2,Stream,EndToken,TList). | |
| 336 | get_term_list_aux2(Token2,_,EndToken,_) :- | |
| 337 | format(user_error,'Unexpected token: ~w, expected ~w~n',[Token2,EndToken]),fail. | |
| 338 | ||
| 339 | term_read(File) :- statistics(walltime,_), | |
| 340 | open(File,read,Stream),read_terms(Stream),close(Stream), | |
| 341 | statistics(walltime,[_,W1]), format('~n% Walltime ~w ms to tokenise and read ~w~n',[W1,File]), | |
| 342 | print_memory_used_wo_gc. | |
| 343 | ||
| 344 | read_terms(Stream) :- | |
| 345 | read_term_from_stream(Stream,Term), | |
| 346 | %read(Stream,Term), % Prolog's read | |
| 347 | write_term(Term,[max_depth(5),numbervars(true)]),nl, | |
| 348 | !, | |
| 349 | (Term = 'end_of_file' -> true | |
| 350 | ; read_terms(Stream)). | |
| 351 | read_terms(Stream) :- | |
| 352 | get_code(Stream,C), | |
| 353 | format(user_error,'Could not process: ~w~n',[C]). | |
| 354 | ||
| 355 | read_test(1) :- | |
| 356 | term_read('../prob_examples/public_examples/B/Demo/Bakery0.prob'). | |
| 357 | read_test(3) :- | |
| 358 | term_read('../prob_examples/public_examples/B/PerformanceTests/Generated/Generated4000.prob'). | |
| 359 | read_test(4) :- | |
| 360 | term_read('../prob_examples/public_examples/B/PerformanceTests/Generated/Generated10000.prob'). | |
| 361 | ||
| 362 | read_test(7) :- | |
| 363 | term_read('../private_examples/ClearSy/2019_Nov/rule_perf4/rule_split.prob'). | |
| 364 | ||
| 365 | read_test(8) :- | |
| 366 | term_read('../prob_examples/public_examples/B/PerformanceTests/SATLIB/sudoku.prob'). | |
| 367 | ||
| 368 | ||
| 369 | ||
| 370 | /* | |
| 371 | ||
| 372 | with new read_term_from_stream: | |
| 373 | ||
| 374 | | ?- read_test(4). | |
| 375 | parser_version(2019-03-05 17:22:26.861) | |
| 376 | classical_b(Generated10000,[/Users/leuschel/git_root/prob_examples/public_examples/B/PerformanceTests/Generated/Generated10000.mch]) | |
| 377 | machine(abstract_machine(pos(1,1,1,1,50007,4),machine(pos(2,1,1,1,1,8)),machine_header(pos(3,1,1,9,1,23),Generated10000,[]),[constants(pos(...),[...|...]),properties(pos(...),conjunct(...)),variables(...)|...])) | |
| 378 | end_of_file | |
| 379 | ||
| 380 | % Walltime 774 ms to tokenise /Users/leuschel/git_root/prob_examples/public_examples/B/PerformanceTests/Generated/Generated10000.prob | |
| 381 | 108.476 MB | |
| 382 | ||
| 383 | with fastreadwrite: | |
| 384 | % Walltime 89 ms to fastread from ./fastrw_out.probz | |
| 385 | 109.004 MB | |
| 386 | ||
| 387 | ||
| 388 | with Prolog read | |
| 389 | | ?- rtest4. | |
| 390 | parser_version(2019-03-05 17:22:26.861) | |
| 391 | classical_b(Generated10000,[/Users/leuschel/git_root/prob_examples/public_examples/B/PerformanceTests/Generated/Generated10000.mch]) | |
| 392 | machine(abstract_machine(pos(1,1,1,1,50007,4),machine(pos(2,1,1,1,1,8)),machine_header(pos(3,1,1,9,1,23),Generated10000,[]),[constants(pos(...),[...|...]),properties(pos(...),conjunct(...)),variables(...)|...])) | |
| 393 | end_of_file | |
| 394 | ||
| 395 | % Walltime 4193 ms to tokenise /Users/leuschel/git_root/prob_examples/public_examples/B/PerformanceTests/Generated/Generated10000.prob | |
| 396 | 286.429 MB | |
| 397 | ||
| 398 | ||
| 399 | % Walltime 102 ms to get_codes /Users/leuschel/git_root/prob_examples/public_examples/B/PerformanceTests/Generated/Generated4000.prob | |
| 400 | ||
| 401 | % Walltime 233 ms to tokenise /Users/leuschel/git_root/prob_examples/public_examples/B/PerformanceTests/Generated/Generated4000.prob | |
| 402 | 116.813 MB ( 11.956 MB program) | |
| 403 | ||
| 404 | ||
| 405 | ||
| 406 | | ?- rtest7. | |
| 407 | parser_version(23928fd10a7a580ccd609bf614ed4552107bbd6a) | |
| 408 | classical_b(rule,[/Users/leuschel/git_root/private_examples/ClearSy/2019_Nov/rule_perf4/rule_split.mch,/Users/leuschel/git_root/prob_prolog/stdlib/CHOOSE.def,/Users/leuschel/git_root/prob_prolog/stdlib/LibraryBits.def,/Users/leuschel/git_root/prob_prolog/stdlib/LibraryCSV.def|...]) | |
| 409 | machine(abstract_machine(pos(4687857,17,1,1,79,4),machine(pos(4687858,17,1,1,1,8)),machine_header(pos(4687859,17,1,9,1,21),LibraryFiles,[]),[abstract_constants(pos(...),[...|...]),properties(pos(...),conjunct(...)),definitions(...)|...])) | |
| 410 | machine(abstract_machine(pos(4688547,18,1,1,94,4),machine(pos(4688548,18,1,1,1,8)),machine_header(pos(4688549,18,1,9,1,20),LibraryMath,[]),[abstract_constants(pos(...),[...|...]),definitions(pos(...),[...|...]),properties(...)|...])) | |
| 411 | machine(abstract_machine(pos(4689324,19,1,1,176,4),machine(pos(4689325,19,1,1,1,8)),machine_header(pos(4689326,19,1,9,1,23),LibraryStrings,[]),[abstract_constants(pos(...),[...|...]),properties(pos(...),conjunct(...)),definitions(...)|...])) | |
| 412 | machine(abstract_machine(pos(1,1,1,1,1929826,4),machine(pos(2,1,1,1,1,8)),machine_header(pos(3,1,2,5,2,9),rule,[]),[definitions(pos(...),[...|...]),sees(pos(...),[...|...]),constants(...)|...])) | |
| 413 | end_of_file | |
| 414 | ||
| 415 | % Walltime 31964 ms to tokenise /Users/leuschel/git_root/private_examples/ClearSy/2019_Nov/rule_perf4/rule_split.prob | |
| 416 | 659.087 MB | |
| 417 | yes | |
| 418 | ||
| 419 | % Walltime 6243 ms to fastread from ./fastrw_out.probz | |
| 420 | 659.025 MB | |
| 421 | ||
| 422 | ||
| 423 | % Walltime 5676 ms to get_codes /Users/leuschel/git_root/private_examples/ClearSy/2019_Nov/rule_perf4/rule_split.prob | |
| 424 | ||
| 425 | % Walltime 15616 ms to tokenise /Users/leuschel/git_root/private_examples/ClearSy/2019_Nov/rule_perf4/rule_split.prob | |
| 426 | 116.840 MB ( 11.982 MB program) | |
| 427 | ||
| 428 | */ | |
| 429 |