jms@sun.acs.udel.edu (John Milbury-Steen) (12/14/89)
We have some applications with large amounts of data, that must be modified a lot during run time. Is it more efficient to use "record" or "assert?" If, for example, you are storing the fact that Fido is brown, is it better to say: record(fido, color(brown), _) or to say: assert(fido(color(brown))) Assume the program knows about 30 attributes of 5000 dogs. (My applications are not really canine). Are recommendations different for Arity Prolog and Quintus? I think asserting might be just as efficient, because once you know the dog, you can find the attribute quickly via first-argument indexing. If you record, the system has to look at attributes sequentially until it finds the attribute you want. This is uninformed speculation. As for "record" I'd wager that "recorda" is better than "recordz" because it ensures that items recently changed are at the top of the data structure (like a stack). Reactions from Those Who Know? -- | John Milbury-Steen (302)451-2698 jms@sun.acs.udel.edu | | Office of Academic Computing and Instructional Technology | | University of Delaware Newark DE 19716 | | "Intellectual awareness does me no good." |
hamid@goedel.uucp (Hamid Bacha) (12/15/89)
In article <5929@sun.acs.udel.edu> jms@sun.acs.udel.edu (John Milbury-Steen) writes: >We have some applications with large amounts of data, >that must be modified a lot during run time. Is >it more efficient to use "record" or "assert?" > >If, for example, you are storing the fact that >Fido is brown, is it better to say: > record(fido, color(brown), _) >or to say: > assert(fido(color(brown))) > >Assume the program knows about 30 attributes of 5000 dogs. >(My applications are not really canine). > >Are recommendations different for Arity Prolog and >Quintus? If your Prolog system is based on an incremental compiler (e.g. ALS-Prolog), you may be better off using record. Assert and retract involve compilation followed by decompilation of the given term. These are two very expensive operations which should be avoided unless you intend to execute the term as a Prolog clause. >I think asserting might be just as efficient, because >once you know the dog, you can find the attribute >quickly via first-argument indexing. If you record, Most Prolog systems do not do first (or Nth) argument indexing on dynamic predicates.