Changeset 1539 for fmts/trunk/p/C0XTKSB.m
- Timestamp:
- Sep 26, 2012, 12:58:34 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fmts/trunk/p/C0XTKSB.m
r1343 r1539 1 C0XTESTKSB ; GPL - Fileman Triples bulk load tester ;11/6/11 17:05 2 ; KSB - modified to fix a minor bug and to use;;;;;Build 7 3 ; high resolution time if routines available ; 11/19/11 1410 EST 4 ;;0.1;C0X;nopatch;noreleasedate;Build 1 5 ;Copyright 2011 George Lilly. Licensed under the terms of the GNU 6 ;General Public License See attached copy of the License. 7 ; 8 ;This program is free software; you can redistribute it and/or modify 9 ;it under the terms of the GNU General Public License as published by 10 ;the Free Software Foundation; either version 2 of the License, or 11 ;(at your option) any later version. 12 ; 13 ;This program is distributed in the hope that it will be useful, 14 ;but WITHOUT ANY WARRANTY; without even the implied warranty of 15 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 ;GNU General Public License for more details. 17 ; 18 ;You should have received a copy of the GNU General Public License along 19 ;with this program; if not, write to the Free Software Foundation, Inc., 20 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 ; 22 Q 23 ; 24 EN ; run the test 25 ; 26 k C0XFDA ; clear the node variable 27 s U="^" ; initialization - Bhaskar 20111119 28 i '$d(^C0X(101,0)) d ; global doesn't exist 29 . s ^C0X(101,0)="C0X TRIPLE^172.101^1^1" 30 n zg 31 S zg="_:G"_$$LKY9 ; all nodes are in the same graph 32 n zi 33 f zi=1:1:10000 d ; try a test of 10000 nodes 34 . s C0XFDA(172.101,zi,.01)="N"_$$LKY17 ; node name 35 . s C0XFDA(172.101,zi,.02)=zg 36 . s C0XFDA(172.101,zi,.03)=$R(100000) 37 . s C0XFDA(172.101,zi,.04)=$R(100000) 38 . s C0XFDA(172.101,zi,.05)=$R(100000) 39 S C0XST=$$H ; start of the insertion test 40 W !,"INSERTION STARTS AT ",$ZDATE(C0XST,"YEAR-MM-DD:24:60:SS"),! 41 d BULKLOAD(.C0XFDA) 42 s C0XEND=$$H ; end of the insertion test 43 W !,"INSERTION ENDS AT ",$ZDATE(C0XEND,"YEAR-MM-DD:24:60:SS") 44 S C0XDIFF=(86400*($P(C0XEND,",",1)-$P(C0XST,",",1)))+$P(C0XEND,",",2)-$P(C0XST,",",2) 45 W !," ELAPSED TIME: ",C0XDIFF," SECONDS" 46 W ! 47 W:C0XDIFF>0 " APPROXIMATELY ",$FN(10000/C0XDIFF,",",0)," NODES PER SECOND",! 48 q 49 ; 50 LKY9() ;EXTRINIC THAT RETURNS A RANDOM 9 DIGIT NUMBER. USED FOR GENERATING 51 ; UNIQUE NODE AND GRAPH NAMES 52 N ZN,ZI 53 S ZN="" 54 F ZI=1:1:9 D ; 55 . S ZN=ZN_$R(10) 56 Q ZN 57 ; 58 LKY17() ;EXTRINIC THAT RETURNS A RANDOM 9 DIGIT NUMBER. USED FOR GENERATING 59 ; UNIQUE NODE AND GRAPH NAMES 60 N ZN,ZI 61 S ZN="" 62 F ZI=1:1:17 D ; 63 . S ZN=ZN_$R(10) 64 Q ZN 65 ; 66 BULKLOAD(ZBFDA) ; BULK LOADER FOR LOADING TRIPLES INTO FILE 172.101 67 ; USING GLOBAL SETS INSTEAD OF UPDATE^DIE 68 ; QUITS IF FILE IS NOT 172.101 69 ; EXPECTS AN FDA WITHOUT STRINGS FOR THE IENS, STARTING AT 1 70 ; QUITS IF FIRST ENTRY IS NOT IENS 1 71 ; ASSUMES THAT THE LAST IENS IS THE COUNT OF ENTRIES 72 ; ZBFDA IS PASSED BY REFERENCE 73 ; 74 ; -- reserves a block of iens from file 172.101 by locking the zero node 75 ; -- ^C0X(101,0) and adding the count of entries to piece 2 and 3 76 ; -- then unlocking to minimize the duration of the lock 77 ; 78 W !,"USING BULKLOAD" 79 I '$D(ZBFDA) Q ; EMPTY FDA 80 I $O(ZBFDA(""))'=172.101 Q ; WRONG FILE 81 N ZCNT,ZP3,ZP4 82 ; -- find the number of nodes to insert 83 S ZCNT=$O(ZBFDA(172.101,""),-1) 84 I ZCNT="" D Q ; 85 . W !,"ERROR IN BULK LOAD - INVALID NODE COUNT" 86 . B 87 ; -- lock the zero node and reserve a block of iens to insert 88 W !,"LOCKING ZERO NODE" 89 LOCK +^C0X(101,0) 90 S ZP3=$P(^C0X(101,0),U,3) 91 S ZP4=$P(^C0X(101,0),U,4) 92 S $P(^C0X(101,0),U,3)=ZP3+ZCNT+1 93 S $P(^C0X(101,0),U,4)=ZP4+ZCNT+1 94 LOCK -^C0X(101,0) 95 N ZI,ZN,ZG,ZS,ZP,ZO,ZIEN,ZBASE 96 S ZBASE=ZP3 ; the last ien in the file 97 W !,"ZERO NODE UNLOCKED, IENS RESERVED=",ZCNT 98 W !,$ZDATE($$H,"YEAR-MM-DD:24:60:SS") 99 S ZI="" 100 F S ZI=$O(ZBFDA(172.101,ZI)) Q:ZI="" D ; 101 . S ZN=$G(ZBFDA(172.101,ZI,.01)) ; node name 102 . I ZN="" D BLKERR Q ; 103 . S ZG=$G(ZBFDA(172.101,ZI,.02)) ; graph pointer 104 . I ZG="" D BLKERR Q ; 105 . S ZS=$G(ZBFDA(172.101,ZI,.03)) ; subject pointer 106 . I ZS="" D BLKERR Q ; 107 . S ZP=$G(ZBFDA(172.101,ZI,.04)) ; predicate pointer 108 . I ZP="" D BLKERR Q ; 109 . S ZO=$G(ZBFDA(172.101,ZI,.05)) ; object pointer 110 . I ZO="" D BLKERR Q ; 111 . S ZIEN=ZI+ZBASE ; the new ien 112 . S ^C0X(101,ZIEN,0)=ZN_U_ZG_U_ZS_U_ZP_U_ZO ; set the zero node 113 . S ^C0X(101,"B",ZN,ZIEN)="" ; the B index 114 . S ^C0X(101,"G",ZG,ZIEN)="" ; the G for Graph index 115 . S ^C0X(101,"SPO",ZS,ZP,ZO)="" 116 . S ^C0X(101,"SOP",ZS,ZO,ZP)="" 117 . S ^C0X(101,"OPS",ZO,ZP,ZS)="" 118 . S ^C0X(101,"OSP",ZO,ZS,ZP)="" 119 . S ^C0X(101,"GOPS",ZG,ZO,ZP,ZS)="" 120 . S ^C0X(101,"GOSP",ZG,ZO,ZS,ZP)="" 121 . S ^C0X(101,"GPSO",ZG,ZP,ZS,ZO)="" 122 . S ^C0X(101,"GSPO",ZG,ZS,ZP,ZO)="" 123 Q 124 ; 125 BLKERR ; 126 W !,"ERROR IN BULK LOAD",! ZWR ZBFDA(ZI) 127 B 128 Q 129 ; 130 H() 131 quit:$length($ztrnlnm("GTMXC_posix"))&$length($text(zhorolog^%POSIX)) $$zhorolog^%POSIX quit $horolog 1 C0XTESTKSB ; GPL - Fileman Triples bulk load tester ;11/6/11 17:05 2 ;;1.0;FILEMAN TRIPLE STORE;;Sep 26, 2012 3 ; KSB - modified to fix a minor bug and to use;;;;;Build 10 4 ; high resolution time if routines available ; 11/19/11 1410 EST 5 ;;0.1;C0X;nopatch;noreleasedate;Build 1 6 ;Copyright 2011 George Lilly. Licensed under the terms of the GNU 7 ;General Public License See attached copy of the License. 8 ; 9 ;This program is free software; you can redistribute it and/or modify 10 ;it under the terms of the GNU General Public License as published by 11 ;the Free Software Foundation; either version 2 of the License, or 12 ;(at your option) any later version. 13 ; 14 ;This program is distributed in the hope that it will be useful, 15 ;but WITHOUT ANY WARRANTY; without even the implied warranty of 16 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 ;GNU General Public License for more details. 18 ; 19 ;You should have received a copy of the GNU General Public License along 20 ;with this program; if not, write to the Free Software Foundation, Inc., 21 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 ; 23 Q 24 ; 25 EN ; run the test 26 ; 27 k C0XFDA ; clear the node variable 28 s U="^" ; initialization - Bhaskar 20111119 29 i '$d(^C0X(101,0)) d ; global doesn't exist 30 . s ^C0X(101,0)="C0X TRIPLE^172.101^1^1" 31 n zg 32 S zg="_:G"_$$LKY9 ; all nodes are in the same graph 33 n zi 34 f zi=1:1:10000 d ; try a test of 10000 nodes 35 . s C0XFDA(172.101,zi,.01)="N"_$$LKY17 ; node name 36 . s C0XFDA(172.101,zi,.02)=zg 37 . s C0XFDA(172.101,zi,.03)=$R(100000) 38 . s C0XFDA(172.101,zi,.04)=$R(100000) 39 . s C0XFDA(172.101,zi,.05)=$R(100000) 40 S C0XST=$$H ; start of the insertion test 41 W !,"INSERTION STARTS AT ",$ZDATE(C0XST,"YEAR-MM-DD:24:60:SS"),! 42 d BULKLOAD(.C0XFDA) 43 s C0XEND=$$H ; end of the insertion test 44 W !,"INSERTION ENDS AT ",$ZDATE(C0XEND,"YEAR-MM-DD:24:60:SS") 45 S C0XDIFF=(86400*($P(C0XEND,",",1)-$P(C0XST,",",1)))+$P(C0XEND,",",2)-$P(C0XST,",",2) 46 W !," ELAPSED TIME: ",C0XDIFF," SECONDS" 47 W ! 48 W:C0XDIFF>0 " APPROXIMATELY ",$FN(10000/C0XDIFF,",",0)," NODES PER SECOND",! 49 q 50 ; 51 LKY9() ;EXTRINIC THAT RETURNS A RANDOM 9 DIGIT NUMBER. USED FOR GENERATING 52 ; UNIQUE NODE AND GRAPH NAMES 53 N ZN,ZI 54 S ZN="" 55 F ZI=1:1:9 D ; 56 . S ZN=ZN_$R(10) 57 Q ZN 58 ; 59 LKY17() ;EXTRINIC THAT RETURNS A RANDOM 9 DIGIT NUMBER. USED FOR GENERATING 60 ; UNIQUE NODE AND GRAPH NAMES 61 N ZN,ZI 62 S ZN="" 63 F ZI=1:1:17 D ; 64 . S ZN=ZN_$R(10) 65 Q ZN 66 ; 67 BULKLOAD(ZBFDA) ; BULK LOADER FOR LOADING TRIPLES INTO FILE 172.101 68 ; USING GLOBAL SETS INSTEAD OF UPDATE^DIE 69 ; QUITS IF FILE IS NOT 172.101 70 ; EXPECTS AN FDA WITHOUT STRINGS FOR THE IENS, STARTING AT 1 71 ; QUITS IF FIRST ENTRY IS NOT IENS 1 72 ; ASSUMES THAT THE LAST IENS IS THE COUNT OF ENTRIES 73 ; ZBFDA IS PASSED BY REFERENCE 74 ; 75 ; -- reserves a block of iens from file 172.101 by locking the zero node 76 ; -- ^C0X(101,0) and adding the count of entries to piece 2 and 3 77 ; -- then unlocking to minimize the duration of the lock 78 ; 79 W !,"USING BULKLOAD" 80 I '$D(ZBFDA) Q ; EMPTY FDA 81 I $O(ZBFDA(""))'=172.101 Q ; WRONG FILE 82 N ZCNT,ZP3,ZP4 83 ; -- find the number of nodes to insert 84 S ZCNT=$O(ZBFDA(172.101,""),-1) 85 I ZCNT="" D Q ; 86 . W !,"ERROR IN BULK LOAD - INVALID NODE COUNT" 87 . B 88 ; -- lock the zero node and reserve a block of iens to insert 89 W !,"LOCKING ZERO NODE" 90 LOCK +^C0X(101,0) 91 S ZP3=$P(^C0X(101,0),U,3) 92 S ZP4=$P(^C0X(101,0),U,4) 93 S $P(^C0X(101,0),U,3)=ZP3+ZCNT+1 94 S $P(^C0X(101,0),U,4)=ZP4+ZCNT+1 95 LOCK -^C0X(101,0) 96 N ZI,ZN,ZG,ZS,ZP,ZO,ZIEN,ZBASE 97 S ZBASE=ZP3 ; the last ien in the file 98 W !,"ZERO NODE UNLOCKED, IENS RESERVED=",ZCNT 99 W !,$ZDATE($$H,"YEAR-MM-DD:24:60:SS") 100 S ZI="" 101 F S ZI=$O(ZBFDA(172.101,ZI)) Q:ZI="" D ; 102 . S ZN=$G(ZBFDA(172.101,ZI,.01)) ; node name 103 . I ZN="" D BLKERR Q ; 104 . S ZG=$G(ZBFDA(172.101,ZI,.02)) ; graph pointer 105 . I ZG="" D BLKERR Q ; 106 . S ZS=$G(ZBFDA(172.101,ZI,.03)) ; subject pointer 107 . I ZS="" D BLKERR Q ; 108 . S ZP=$G(ZBFDA(172.101,ZI,.04)) ; predicate pointer 109 . I ZP="" D BLKERR Q ; 110 . S ZO=$G(ZBFDA(172.101,ZI,.05)) ; object pointer 111 . I ZO="" D BLKERR Q ; 112 . S ZIEN=ZI+ZBASE ; the new ien 113 . S ^C0X(101,ZIEN,0)=ZN_U_ZG_U_ZS_U_ZP_U_ZO ; set the zero node 114 . S ^C0X(101,"B",ZN,ZIEN)="" ; the B index 115 . S ^C0X(101,"G",ZG,ZIEN)="" ; the G for Graph index 116 . S ^C0X(101,"SPO",ZS,ZP,ZO)="" 117 . S ^C0X(101,"SOP",ZS,ZO,ZP)="" 118 . S ^C0X(101,"OPS",ZO,ZP,ZS)="" 119 . S ^C0X(101,"OSP",ZO,ZS,ZP)="" 120 . S ^C0X(101,"GOPS",ZG,ZO,ZP,ZS)="" 121 . S ^C0X(101,"GOSP",ZG,ZO,ZS,ZP)="" 122 . S ^C0X(101,"GPSO",ZG,ZP,ZS,ZO)="" 123 . S ^C0X(101,"GSPO",ZG,ZS,ZP,ZO)="" 124 Q 125 ; 126 BLKERR ; 127 W !,"ERROR IN BULK LOAD",! ZWR ZBFDA(ZI) 128 B 129 Q 130 ; 131 H() 132 quit:$length($ztrnlnm("GTMXC_posix"))&$length($text(zhorolog^%POSIX)) $$zhorolog^%POSIX quit $horolog
Note:
See TracChangeset
for help on using the changeset viewer.