Pular para o conteúdo principal

Postagem em destaque

🚀 Oferecendo Serviços Remotos de Desenvolvedor AdvPL e Mais 🖥️

🚀 Oferecendo Serviços Remotos de Desenvolvedor AdvPL e Mais 🖥️ Olá pessoal, Espero que este post encontre todos vocês bem! É com grande entusiasmo que compartilho que estou expandindo meus serviços como Desenvolvedor AdvPL para novos desafios e colaborações. Com mais de duas décadas de experiência sólida, minha jornada profissional tem sido enriquecedora, com a oportunidade de participar de projetos empolgantes ao longo dos anos. Agora, estou ansioso para trazer minha experiência e habilidades para novas equipes e projetos, trabalhando de forma remota. Minha expertise abrange não apenas AdvPL, mas também outras tecnologias-chave, incluindo JS, SQL, Infraestrutura e Otimização de Processos. Acredito que essa combinação de conhecimentos me permite oferecer soluções abrangentes e eficazes para uma variedade de necessidades de desenvolvimento. Acredito que a tecnologia tem o poder de transformar negócios e impulsionar o sucesso, e estou comprometido em ajudar meus clientes a alcançar seu

BlackTDN :: stringtst :: Harbour (win) x totvsappserver (String size overflow!)

image Baseado em memtst.prg, stringtst.prg surgiu para testar os limites definidos pela área de Tecnologia da Totvs para o tamanho máximo que uma string pode ter. Nesse novo teste totvsapp decepcionou. Não passou de 1/10.

No teste 1/10, e para appserver (build: 7.00.101202A-20110330), a última stringtst Length foi de: 1.048.572 o máximo é de 1.048.575 ( + 1: String size overflow! ).

Já no aplicativo compilado pelo harbour 3.1.0dev (Rev. 17207) no teste 10/10, a última stringtst Length foi de: 103.302.755

Podemos concluir, com esse teste:

Que harbour venceu de 10x0 contra totvsapserver e que o tamanho de uma string, em advpl, ainda é muito limitado; que, no harbour, o tamanho de uma string é limitada pelo tamanho da memória disponível e, no totvsappserver, ela é limitada via código.

Eis o código do teste:

   1: /*
   2:  * $Id: stringtst.prg
   3:  * baseado no original de: Harbour Project source code: $Id: memtst.prg 13932 2010-02-20 11:57:17Z vszakats $
   4:  * a small memory manager test code
   5:  */
   6: #define N_LOOPS      (1000*1000)
   7: #define N_MAXLOOP             10
   8: #define WHITE_SPACE         1024
   9: #define MAX_SIZE_ARRAY    100000
  10:  
  11: #ifndef HB_SYMBOL_UNUSED
  12:      #define HB_SYMBOL_UNUSED( symbol ) ( symbol := ( symbol ) )
  13: #endif
  14:  
  15: #ifdef __HARBOUR__
  16:     #include "simpleio.ch"
  17:     #include "hbmemory.ch"
  18: #else
  19:     #xcommand ?  [<list,...>] => ConOut( [ <list> ] )
  20:     #xcommand ?? [<list,...>] => ConOut( [ <list> ] )
  21:     #xtranslate hb_secondsCPU() => seconds()
  22:     #ifdef TOTVS
  23:         #include "totvs.ch"
  24:     #else
  25:         #include "protheus.ch"
  26:     #endif    
  27: #endif
  28: //-----------------------------------------------------------------------------------------------------------
  29: #ifdef __HARBOUR__
  30: procedure main()
  31:     local cCRLF        := hb_OsNewLine()
  32:     local cVersion     := VERSION()+build_mode()
  33:     local cOS          := OS()
  34: #else
  35: user function stringtst()
  36:     local cCRLF        := CRLF
  37:     local cVersion     := "TOTVS APPServer " + GetVersao(.T.,.F.) + " " + GetBuild() + " " + GetRPORelease()
  38:     local cOS          := IF( IsSrvUnix() , "Unix/Linux", "Windows" )     
  39: #endif
  40:     local dDate
  41:     local cTime
  42:     local t
  43:     local nCPUSec
  44:     local nRealSec
  45:     local nSizeArr     := 100
  46:     local cWSpace      := ""
  47:     local nfhandle
  48:     local cstringtst
  49:  
  50:     SET DATE TO BRITISH
  51:     SET CENTURY ON
  52:  
  53:     for t := 1 to N_MAXLOOP
  54:     
  55:         nRealSec    := seconds()
  56:         nCPUSec     := hb_secondsCPU()
  57:     
  58:         nfhandle    := fCreate( "stringstst" + StrZero(t,10) + ".log" )
  59:         IF ( nfhandle < 0 )
  60:              ? "Can not start a test: " + Str( t )
  61:              loop
  62:         EndIF
  63:      
  64:         dDate := date()
  65:         cTime := Time()
  66:      
  67:         ? dDate, cTime, cVersion+", "+cOS
  68:         cstringtst := dtoc( dDate ) + ", " + cTime + ", " + cVersion+", "+cOS + cCRLF
  69:         #ifndef __HARBOUR__
  70:             ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
  71:         #endif
  72:      
  73:         #ifdef __HARBOUR__
  74:              if MEMORY( HB_MEM_USEDMAX ) != 0
  75:                  ?
  76:                 cstringtst += cCRLF
  77:                 #ifndef __HARBOUR__
  78:                      ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
  79:                 #endif
  80:                 ? "Warning !!! Memory statistic enabled."
  81:                 cstringtst += "Warning !!! Memory statistic enabled." + cCRLF
  82:                 #ifndef __HARBOUR__
  83:                      ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
  84:                 #endif
  85:              endif
  86:         #endif
  87:  
  88:         nSizeArr    := Min( nSizeArr * 10 , MAX_SIZE_ARRAY )
  89:         cWSpace     += Space( WHITE_SPACE )
  90:  
  91:         ?
  92:         cstringtst += cCRLF
  93:         #ifndef __HARBOUR__
  94:              ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
  95:         #endif
  96:         
  97:         cstringtst += "Len( cWSpace ) :" + Transform( Len( cWSpace ) , "9999999999" ) + cCRLF
  98:         #ifndef __HARBOUR__
  99:              ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 100:         #endif
 101:         
 102:         cstringtst += cCRLF
 103:         #ifndef __HARBOUR__
 104:              ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 105:         #endif
 106:  
 107:         cstringtst += stringtst(@cCRLF,@t,@nSizeArr,@cWSpace)
 108:         #ifndef __HARBOUR__
 109:              ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 110:         #endif
 111:  
 112:         dDate       := date()
 113:         cTime       := Time()
 114:         nCPUSec     := hb_secondsCPU() - nCPUSec
 115:         nRealSec    := seconds() - nRealSec
 116:  
 117:         ?
 118:         cstringtst += cCRLF
 119:         #ifndef __HARBOUR__
 120:              ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 121:         #endif
 122:  
 123:         ? dDate, cTime, cVersion+", "+cOS
 124:         cstringtst += dtoc( dDate ) + ", " + cTime + ", " + cVersion+", "+cOS + cCRLF
 125:         #ifndef __HARBOUR__
 126:              ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 127:         #endif
 128:  
 129:         ?
 130:         cstringtst += cCRLF
 131:         #ifndef __HARBOUR__
 132:              ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 133:         #endif
 134:       
 135:         ? " CPU time (total):", nCPUSec, "sec."
 136:         cstringtst += " CPU time (total):" + Transform(  nCPUSec , "99999.9999999999" )  + " sec." + cCRLF
 137:         #ifndef __HARBOUR__
 138:              ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 139:         #endif
 140:          
 141:         ? "real time (total):", nRealSec, "sec."
 142:         cstringtst += "real time (total):" + Transform( nRealSec , "99999.9999999999" ) + " sec." + cCRLF
 143:         ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 144:  
 145:         fWrite( nfhandle , @cstringtst )
 146:         fWrite( nfhandle , "stringtst Length:" + Transform( Len(cstringtst) , "9999999999" ) + cCRLF )
 147:           
 148:         cstringtst := NIL
 149:  
 150:         fClose( nfhandle )
 151:  
 152:     next t
 153:  
 154:     cWSpace := NIL
 155:  
 156: Return
 157: //-----------------------------------------------------------------------------------------------------------
 158: static function stringtst(cCRLF,t,nSizeArr,cWSpace)
 159:  
 160:     local i
 161:     local a
 162:     local nCPUSec
 163:     local nRealSec
 164:     local nCRLF
 165:     local lFree := .F.
 166:     local cstringtst
 167:     
 168:     ?
 169:     cstringtst := cCRLF
 170:     #ifndef __HARBOUR__
 171:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 172:     #endif
 173:     ? "testing single large memory blocks allocation and freeing..."
 174:     cstringtst += "testing single large memory blocks allocation and freeing..."+ cCRLF
 175:     #ifndef __HARBOUR__
 176:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 177:     #endif
 178:     
 179:     ?
 180:     cstringtst += cCRLF
 181:     #ifndef __HARBOUR__
 182:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 183:     #endif
 184:     
 185:     nRealSec    := seconds()
 186:     nCPUSec     := hb_secondsCPU()
 187:  
 188:     for i := 1 to ( t * N_LOOPS )
 189:         a := cWSpace
 190:         HB_SYMBOL_UNUSED( a )
 191:         a := ""
 192:         HB_SYMBOL_UNUSED( a )
 193:         a := NIL
 194:     next i
 195:  
 196:     nCPUSec     := hb_secondsCPU() - nCPUSec
 197:     nRealSec    := seconds() - nRealSec
 198:  
 199:     ? " CPU time:", nCPUSec, "sec."
 200:     cstringtst += " CPU time:" + Transform(  nCPUSec , "99999.9999999999" )  + " sec." + cCRLF
 201:     #ifndef __HARBOUR__
 202:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 203:     #endif
 204:     
 205:     ? "real time:", nRealSec, "sec."
 206:     cstringtst += "real time:" + Transform( nRealSec , "99999.9999999999" ) + " sec." + cCRLF
 207:     #ifndef __HARBOUR__
 208:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 209:     #endif
 210:     
 211:     ?
 212:     cstringtst += cCRLF
 213:     #ifndef __HARBOUR__
 214:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 215:     #endif
 216:    
 217:     ? "testing many large memory blocks allocation and freeing..."     
 218:     ?
 219:    
 220:     cstringtst += cCRLF
 221:     #ifndef __HARBOUR__
 222:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 223:     #endif
 224:     cstringtst += "testing many large memory blocks allocation and freeing..." + cCRLF
 225:     #ifndef __HARBOUR__
 226:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 227:     #endif
 228:     
 229:     ?
 230:     cstringtst += cCRLF
 231:     #ifndef __HARBOUR__
 232:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 233:     #endif
 234:  
 235:     nRealSec    := seconds()
 236:     nCPUSec     := hb_secondsCPU()
 237:     a           := Array(nSizeArr)
 238:     nCRLF       := 0
 239:     for i := 1 to ( t * N_LOOPS )
 240:         a[ i % 100 + 1 ] := cWSpace
 241:         cstringtst += Transform( i % 100 + 1  , "9999999999" )
 242:         #ifndef __HARBOUR__
 243:              ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 244:         #endif
 245:         IF ( ( ++nCRLF % 10 ) == 0 )
 246:             cstringtst += cCRLF
 247:             #ifndef __HARBOUR__
 248:                  ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 249:             #endif
 250:         EndIF
 251:         if i % 200 == 0
 252:             cstringtst += cCRLF
 253:             #ifndef __HARBOUR__
 254:                  ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 255:             #endif
 256:             IF ( lFree )
 257:                 lFree := .F.
 258:                 afill(a,"")
 259:                 ? "Free  :",i
 260:                 cstringtst += "Free  : " + Transform( i  , "9999999999" ) + cCRLF
 261:                 #ifndef __HARBOUR__
 262:                      ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 263:                 #endif
 264:             Else
 265:                 lFree := .T.
 266:                 afill(a,cWSpace)
 267:                 ? "Alloc :",i
 268:                 cstringtst += "Alloc : " + TransForm( i  , "9999999999" ) + cCRLF
 269:                 #ifndef __HARBOUR__
 270:                      ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 271:                 #endif
 272:             EndIF
 273:             cstringtst += cCRLF
 274:             #ifndef __HARBOUR__
 275:                  ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 276:             #endif
 277:         endif
 278:     next i
 279:  
 280:     aSize( a , 0 )
 281:     a           := NIL
 282:     nCPUSec     := hb_secondsCPU() - nCPUSec
 283:     nRealSec    := seconds() - nRealSec
 284:  
 285:     ? " CPU time:", nCPUSec, "sec."
 286:     cstringtst += " CPU time:" + Transform( nCPUSec  , "99999.9999999999" )  + " sec." + cCRLF
 287:     #ifndef __HARBOUR__
 288:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 289:     #endif
 290:     
 291:     ? "real time:", nRealSec, "sec."
 292:     cstringtst += "real time:" + Transform( nRealSec  , "99999.9999999999" ) + " sec." + cCRLF
 293:     #ifndef __HARBOUR__
 294:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 295:     #endif
 296:     
 297:     ?
 298:     cstringtst += cCRLF
 299:     #ifndef __HARBOUR__
 300:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 301:     #endif
 302:  
 303:     ? "testing large memory block reallocation with intermediate allocations..."
 304:  
 305:     cstringtst += "testing large memory block reallocation with intermediate allocations..." + cCRLF
 306:     #ifndef __HARBOUR__
 307:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 308:     #endif
 309:  
 310:     ? "Warning!!! some compilers may badly fail here"
 311:  
 312:     ?
 313:     cstringtst += cCRLF
 314:     #ifndef __HARBOUR__
 315:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 316:     #endif
 317:     
 318:     cstringtst += "Warning!!! some compilers may badly fail here" + cCRLF
 319:     #ifndef __HARBOUR__
 320:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 321:     #endif
 322:  
 323:     ?
 324:     cstringtst += cCRLF
 325:     #ifndef __HARBOUR__
 326:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 327:     #endif
 328:  
 329:     IdleSleep( 2 )
 330:     
 331:     nRealSec    := seconds()
 332:     nCPUSec     := hb_secondsCPU()
 333:     nCRLF       := 0
 334:     a           := Array(0)
 335:     for i := 1 to ( t * N_LOOPS )
 336:         aadd( a, { cWSpace } )
 337:         if i%1000 == 0
 338:             ?? i
 339:             cstringtst += Transform( i  , "9999999999" )
 340:             #ifndef __HARBOUR__
 341:                  ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 342:             #endif
 343:             if ( ( ++nCRLF % 10 ) == 0 )
 344:                 cstringtst += cCRLF
 345:                 #ifndef __HARBOUR__
 346:                      ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 347:                 #endif
 348:             endif
 349:         endif
 350:     next i
 351:  
 352:     cstringtst += cCRLF
 353:     #ifndef __HARBOUR__
 354:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 355:     #endif
 356:     aSize( a , 0 )
 357:     a           := NIL
 358:     nCPUSec     := hb_secondsCPU() - nCPUSec
 359:     nRealSec    := seconds() - nRealSec
 360:  
 361:     ? " CPU time:", nCPUSec, "sec."
 362:     cstringtst += " CPU time:" + Transform( nCPUSec  , "99999.9999999999" )  + " sec." + cCRLF
 363:         #ifndef __HARBOUR__
 364:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 365:     #endif
 366:     
 367:     ? "real time:", nRealSec, "sec."
 368:     cstringtst += "real time:" + Transform( nRealSec  , "99999.9999999999" ) + " sec." + cCRLF
 369:     #ifndef __HARBOUR__
 370:          ? "stringtst Length:" , Transform( Len(cstringtst) , "9999999999" ) + cCRLF
 371:     #endif
 372:     
 373:     IdleSleep( 2 )
 374:  
 375: return( cstringtst )
 376: //-----------------------------------------------------------------------------------------------------------
 377: static procedure IdleSleep( n )
 378:     #ifdef __HARBOUR__
 379:         n += seconds()
 380:         while seconds() < n
 381:         enddo
 382:     #else
 383:         Sleep( n )
 384:     #endif
 385: return
 386: //-----------------------------------------------------------------------------------------------------------
 387: #ifndef PROTHEUS
 388:     #ifndef TOTVS
 389:         static function build_mode()
 390:         #ifdef __CLIP__
 391:            return " (MT)"
 392:         #else
 393:            #ifdef __XHARBOUR__
 394:               return iif( HB_MULTITHREAD(), " (MT)", "" ) + ;
 395:                      iif( MEMORY( HB_MEM_USEDMAX ) != 0, " (FMSTAT)", "" )
 396:            #else
 397:               #ifdef __HARBOUR__
 398:                  return iif( HB_MTVM(), " (MT)", "" ) + ;
 399:                         iif( MEMORY( HB_MEM_USEDMAX ) != 0, " (FMSTAT)", "" )
 400:               #else
 401:                  #ifdef __XPP__
 402:                     return " (MT)"
 403:                  #else
 404:                     return ""
 405:                  #endif
 406:               #endif
 407:            #endif
 408:         #endif
 409:     #endif
 410: #endif 

[]s
иαldσ dj

Comentários

  1. Q porra de limite carai? To ligado que vc quebra isso facinho facinho! Rs...
    Vou levar essa brincadeira para o ByYou Lee... lembra que o devorador de WS la nao decepcionou!!! Abraço

    ResponderExcluir

Postar um comentário

Postagens mais visitadas deste blog

BlackTDN :: RLeg ~ Desvendando a Função ParamBox

Para quem precisar desenvolver uma interface de entrada de dados, coisa rápida, e não quer ter aquele trabalhão danado que todos já sabemos, o Protheus tem uma função que ajuda muito, é uma interface semelhante a função Pergunte, porém com muito mais opção de objeto de entrada de dados, alias até colocar o scrollbox desta interface com todos os objetos em outra MsDialog ou Wizard é simples. Vejam o exemplo abaixo, boa sorte! Rleg. //---------------------------------------------------------- // Função exemplo utilizando a função ParamBox() //---------------------------------------------------------- User Function xParamBox() Local aRet := {} Local aParamBox := {} Local aCombo := {"Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"} Local i := 0 Private cCadastro := "xParambox" // ---------------

Protheus :: Chamando Funções do Menu Diretamente e sem a Necessidade de Login

Ferne$ perguntou: "...é possível abrir alguma rotina do sistema sem solicitar login ao usuário, como por exemplo a rotina MATA010..." Sim Ferne$, é possível sim. Abaixo um Exemplo para a Chamada à função MATA010 sem a necessidade de Login no sistema. #INCLUDE "PROTHEUS.CH" #INCLUDE "TBICONN.CH" /*/ Funcao: MATA010Ex Data: 30/04/2011 Autor: Marinaldo de Jesus Descricao: Executar a Funcao MATA010 diretamente sem a necessidade de LOGIN no Protheus Sintaxe: 1 ) U_MATA010Ex ( Chamada diretamente na Tela de Entrada do Sistema ) ; ou 2 ) totvsclient.exe -q -p=u_MATA010Ex -a=01;01 -c=rnp_local -e=rnp -m -l ( Chamada Via Linha de Comando ) /*/ User Function MATA010Ex( cEmpFil ) Local aEmpFil Local bWindowInit := { || __Execute( "MATA010()" , "xxxxxxxxxxxxxxxxxxxx" , "MATA010" , "SIGAFAT" , "SIGAFAT", 1 , .T. ) } Local cEmp Local cFil Local cMod Local cModName := "SIGAFAT" DEFA

BlackTDN :: Customizando a interface de Login no Protheus e by You

A publicação “ BlackTDN :: By You e sua nova tela de login ”  de nosso amigo OBona deu o que falar e, em função disso, esse que a muito não vos escreve resolveu criar uma versão onde será possível personalizar, “por completo”, a tela de login no Protheus/by You. Considerando que OBona já havia “mapeado, identificado e customizado” as imagens peguei-as emprestadas para o exemplo que se segue: O primeiro passo para a customização “total” da interface de login do Protheus/by You será implementar o “Ponto de Entrada” ChgPrDir (Diretório de impressão) . Usaremos esse PE juntamente como programa U_FindMsObject.prg (apresentado pela primeira vez em: Protheus :: ADVPL : The Container : Presents Pandora's box ). Diferente do exemplo proposto por OBona, que substitui, durante o processo de compilação, as imagens padrões do sistema (excluindo-as) por imagens customizadas (com o mesmo nome) este novo exemplo mantém, no RPO, as imagens padrões adicionando novas imagens customizadas que serã