Skip to content

Commit

Permalink
pp.c
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed Nov 22, 2023
1 parent d935c8f commit 85cb7ac
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions pp.c
Expand Up @@ -693,11 +693,63 @@ PP(pp_gelem)
}

/* Pattern matching */
struct rusage previous_rusage;

PP(pp_study)
{
SV *sv = *PL_stack_sp;
STRLEN len;
#ifdef PERL_IMPLICIT_CONTEXT
# ifdef WIN32
# include "Sysinfoapi.h"
MEMORYSTATUSEX statex;
statex.dwLength = sizeof (statex);
GlobalMemoryStatusEx (&statex);

DEBUG_U(PerlIO_printf(Perl_debug_log, "%s:%d:%p: %llu\n", __FILE__, __LINE__, aTHX_ statex.ullAvailVirtual));
# else
/*DEBUG_U(PerlIO_printf(Perl_debug_log, "%s:%d:%p: %p\n", __FILE__, __LINE__, aTHX_ sbrk((intptr_t) 0)));*/
# endif
#endif
struct rusage current_rusage;
errno = 0;
if (getrusage(RUSAGE_SELF, &current_rusage) != 0) {
PerlIO_printf(Perl_debug_log, "%s:%d: getrusage failed: %d\n",
__FILE__, __LINE__, get_extended_os_errno());
}
else {
PerlIO_printf(Perl_debug_log, "%s:%d: "
"max resident set size=%ld\n"
" integral shared text memory size=%ld\n"
" integral unshared data size=%ld\n"
" integral unshared stack size=%ld\n"
" page reclaims=%ld\n"
" page faults=%ld\n"
" swaps=%ld\n"
" block input operations=%ld\n"
" block output operations=%ld\n"
" messages sent=%ld\n"
" messages received=%ld\n"
" signals received=%ld\n"
" voluntary context switches=%ld\n"
" involuntary context switches=%ld\n",
__FILE__, __LINE__,
current_rusage.ru_maxrss,
current_rusage.ru_first,
current_rusage.ru_idrss,
current_rusage.ru_isrss,
current_rusage.ru_minflt,
current_rusage.ru_majflt,
current_rusage.ru_nswap,
current_rusage.ru_inblock,
current_rusage.ru_oublock,
current_rusage.ru_msgsnd,
current_rusage.ru_msgrcv,
current_rusage.ru_nsignals,
current_rusage.ru_nvcsw,
current_rusage.ru_nivcsw);
}


(void)SvPV(sv, len);
if (len == 0 || len > I32_MAX || !SvPOK(sv) || SvUTF8(sv) || SvVALID(sv)) {
Expand Down

0 comments on commit 85cb7ac

Please sign in to comment.